本文介绍了在调用fill之前,selectcommand属性是否尚未初始化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

公开列表<清单> GetCheckListDetails(int BusinessTypeId,int FilingTypeId)

{

List< checklist> list = new List< checklist>();

尝试

{

使用(var dao = DbActivity.Open())

{



CSqlDbCommand cmd = new CSqlDbCommand(DBProcedures.WorkOrderSearch.USP_INSERT_BUSINESSFILLING_DETAILS);



cmd.Parameters.AddWithValue(BusinessTypeId,BusinessTypeId);

cmd.Parameters.AddWithValue(FilingTypeId,FilingTypeId);

SqlDataAdapter da = new SqlDataAdapter() ;



DataSet ds = new DataSet();

da.Fill(ds);

list = (来自c在ds.Tables [0] .AsEnumerable()

选择新的CheckList()

{

CheckListId = c [0] .ToInt() ,

Deatil = c [1] .ToStr(),



})。ToList();

}



}



catch(例外情况)

{

Logger.Database.Error(ex.Message,ex);

throw;

}



返回列表;



}



这是我要执行的方法抛出一个名为selectcommand属性的错误,在调用fill之前还没有被初始化?如何解决?



提前感谢

public List<checklist> GetCheckListDetails(int BusinessTypeId, int FilingTypeId)
{
List<checklist> list = new List<checklist>();
try
{
using (var dao = DbActivity.Open())
{

CSqlDbCommand cmd = new CSqlDbCommand(DBProcedures.WorkOrderSearch.USP_INSERT_BUSINESSFILLING_DETAILS);

cmd.Parameters.AddWithValue("BusinessTypeId", BusinessTypeId);
cmd.Parameters.AddWithValue("FilingTypeId", FilingTypeId);
SqlDataAdapter da = new SqlDataAdapter();

DataSet ds = new DataSet();
da.Fill(ds);
list = (from c in ds.Tables[0].AsEnumerable()
select new CheckList()
{
CheckListId = c[0].ToInt(),
Deatil = c[1].ToStr(),

}).ToList();
}

}

catch (Exception ex)
{
Logger.Database.Error(ex.Message, ex);
throw;
}

return list;

}

this is my method to be executed and it is throwing an error called the selectcommand property has not been initialized before calling fill? how to fix it?

thanks in advance

推荐答案


这篇关于在调用fill之前,selectcommand属性是否尚未初始化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-20 11:16