為什麼 我的ds.Tables.Count 老是為0? DataGrid 也能顯示數據!

hunter_32 2004-11-21 09:50:50
為什麼 我的ds.Tables.Count 老是為0? DataGrid 也能顯示數據!
為什麼啊? 高手幫忙了!
-----------------------------------------------------------------
SqlDataAdapter Da= new SqlDataAdapter(sqlComm);
DataSet Ds= new DataSet();
Da.Fill(Ds,"tempcar");

DataGrid1.DataSource=Ds;
DataGrid1.ShowHeader=true;
DataGrid1.DataBind();
int ttt = ds.Tables.Count; //問題點
if(ds.Tables.Contains("tempcar"))
{
ttt = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());
Session["CurrentPage"] = ttt;
}
sqlConn.Close();
...全文
148 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
SimerJoe 2004-11-21
  • 打赏
  • 举报
回复
ds.Tables[0].Rows[0][0].ToString() ??
ds.Tables[0].Rows[0] //此时得到第0行
ds.Tables[0].Rows[0][0] //现在得第0行的第0个??
ttt = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());
//ttt=第一个记录的第一列的值。

你在哪儿把ttt显示出来的??调试过程中吗?还是界面上的标签等控件?
CraxyMouse 2004-11-21
  • 打赏
  • 举报
回复
int ttt = ds.Tables[0].Rows.Count;
hunter_32 2004-11-21
  • 打赏
  • 举报
回复
調試過程中顯示 看結果正確不

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧