【发布时间】:2015-06-09 22:15:57
【问题描述】:
假设我有一个用 C# 编写的 3 层 ASP.NET 应用程序。您应该如何正确使用 DAL、BLL 和 PL?
例如,假设我有一个存储过程,它需要在返回结果之前传入一个客户 ID 参数。在我的数据访问层中,我可以拥有以下内容:
public DataTable GetCustomerInfo(collection b)
{
DataTable table;
try
{
string returnValue = string.Empty;
DB = Connect();
DBCommand = connection.Procedure("sp_getCust");
DB.AddInParameter(DBCommand, "@CustomerID", DbType.String, b.CustomerID);
DbDataReader reader = DBCommand.ExecuteReader();
table = new DataTable();
table.Load(reader);
return table;
}
catch (Exception ex)
{
throw (ex);
}
}
然后在我的 BLL 中,我会获取返回的表并填充数据集?
我试图在没有我的DataTable 的情况下填充数据集,称为“table”
public static DataTable returnCustomer(collection b)
{
try
{
SqlDataAdapter adapt = new SqlDataAdapter();
DataSet table = new DataSet();
adapt.Fill(table, "table");
return table;
}
catch (Exception ex)
{
throw ex;
}
}
但是我得到了这些错误:
另外:如何绑定数据集以便我可以将数据返回到我的文本框?
【问题讨论】:
标签: c# asp.net datatable dataset