在C#中调用dataset中的table[0]时老是提示找不到table[0]怎么办? 在C#中调用dataset中的table[0]时老是提示找不到table[0]怎么办?我也给dataset用fill填充了,就是提示找不到table[0]呀,请各位高手帮忙呀 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 strSql = strSql + " where InventoryScheduleID ='" + InventoryScheduleID +"'"; strSql = strSql +" and CountNo = " + InCountNO ; strSql = strSql + " and CountLine =" + InCountLine ; DataSet ds = new DataSet(); try { SqlCommand cmd = new SqlCommand(strSql, cn); SqlDataAdapter myDataAdapter = new SqlDataAdapter(); myDataAdapter.SelectCommand = cmd; myDataAdapter.Fill(ds); cmd.Dispose(); myDataAdapter.Dispose(); cn.Close();// ds = DBProc.OpenDataSet(strSql); } catch(SqlReadFailedException ex) { message.ShowMessage("DataSetOpenFailed", ex.Message); return false; }// int TablesCount = ds.Tables.Count;// if (TablesCount == 0)// {// ds.Reset();// ds = DBProc.OpenDataSet(strSql);// } if(ds.Tables[0].Rows.Count == 0) { return false; } else { return true; }以上就是我写的一段程序,当执行到if(ds.Tables[0].Rows.Count == 0)时就报错说找不到table[0],我找了好几天了也没找出错,头都大了。 SqlDataAdapter myDataAdapter = new SqlDataAdapter(strSql, cn);myDataAdapter.Fill(ds,"MyDataTable");这样子看看 正则表达式匹配 winform调用webservices的问题 C# asp.net动态修改web.config出错:"该配置是只读的" session重新赋值,赋值页面,跳转后页面 验证码不能执行,求救!!!!! 散分再求,动态添加控件的问题,在线等 一般人我还不告诉他 ,送分了!!~~ (附带一个小问题,参数传递) ********进来看看C#的提示信息************** C#新浪微博模拟登录问题 自定义控件事件问题!!!!! 请教关于缓存数据的问题 字符串排序后输出?
strSql = strSql +" and CountNo = " + InCountNO ;
strSql = strSql + " and CountLine =" + InCountLine ; DataSet ds = new DataSet();
try
{
SqlCommand cmd = new SqlCommand(strSql, cn);
SqlDataAdapter myDataAdapter = new SqlDataAdapter();
myDataAdapter.SelectCommand = cmd;
myDataAdapter.Fill(ds);
cmd.Dispose();
myDataAdapter.Dispose();
cn.Close();
// ds = DBProc.OpenDataSet(strSql);
}
catch(SqlReadFailedException ex)
{
message.ShowMessage("DataSetOpenFailed", ex.Message);
return false;
}
// int TablesCount = ds.Tables.Count;
// if (TablesCount == 0)
// {
// ds.Reset();
// ds = DBProc.OpenDataSet(strSql);
// }
if(ds.Tables[0].Rows.Count == 0)
{
return false;
}
else
{
return true;
}
以上就是我写的一段程序,当执行到if(ds.Tables[0].Rows.Count == 0)时就报错说找不到table[0],我找了好几天了也没找出错,头都大了。
myDataAdapter.Fill(ds,"MyDataTable");
这样子看看