It looks that the old SqlHelper class from the Microsoft Enterprise Library has 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, Comma开发者_开发知识库ndType.Text, strlSql);
CheckBoxList1.DataTextField = "Technology";
CheckBoxList1.DataBind();
}
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.
thanks in advance.
It's pretty much the same, just varies in its construction, e.g.:
var database = new SqlDatabase("<connection>");
using (var reader = database.ExecuteReader(...))
{
}
精彩评论