本文介绍了替代Microsoft数据访问ApplicationBlocks过时把SqlHelper类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看起来从微软企业库老把SqlHelper类一直主要由包含在新的企业库5.0版本的数据库类取代。

It looks that the old SqlHelper class from the Microsoft Enterprise Libraryhas been mostly replaced by the Database class which is included in the new Enterprise Library version 5.

我有一个非常简单的小例子:

I have a very simple and trivial example:

using Microsoft.ApplicationBlocks.Data;

private void PopulateCheckBoxGroup()
 {
     const string strConnTxt = "Server=(local);Database=DataBindTests;Integrated Security=True;";
     const string strlSql = "select Technology from PreferredTechnology where ParentId = 1";
     CheckBoxList1.DataSource = SqlHelper.ExecuteReader(strConnTxt, CommandType.Text, strlSql);
     CheckBoxList1.DataTextField = "Technology";
     CheckBoxList1.DataBind();

 }

你能给我只是一个提示,以便使用替代的提供SQLHelper新的数据库抽象类做的一样吗?我研究过企业库5手把手实验室,并没有提到这件事。

Can you give me just a hint in order to do the same using the new Database abstract class that replaced the SQLHelper?I have looked into the Enterprise Library 5 "Hands On Labs" and there is no mention about it.

在此先感谢。

推荐答案

这是pretty的大致相同,只是在不同的建筑,如:

It's pretty much the same, just varies in its construction, e.g.:

var database = new SqlDatabase("<connection>");
using (var reader = database.ExecuteReader(...))
{

}

这篇关于替代Microsoft数据访问ApplicationBlocks过时把SqlHelper类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 07:43