如何判断DataSet里面是否有数据? 对不起,打错了ds.Tables[0].Rows.Count 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ds.Tables.Countds.Tables[0].Rows.Count最好两个都使用 ds.tables.count判断有几个表ds.tables[i].rows.count判断某个表是否有数据 if(ds!=null && ds.Tables.Count>0 && ds.Tables[0].Rows.Count>0){} 必须要对dataset里的每个dataTable 进行判断:bool flag=true; //用来判断DataTable中有无数据的标志。如果某个表中有数据,则flag=false。for each (DataTable dt in ds){ if(dt.Rows.Count>0) { flag=false; exit for; }}if(!flag){ //有数据。}else{ //无数据。} 按你的想法,只能如下了:if(ds!=null && ds.Tables.Count>0 ){ for (int i=0; i<ds.Tables.Count;i++) { if (ds.Tables[i].Rows.Count>0) { System.Console.Write("有数据!") break; } }}(也把数据给取出来了)int tmpInt=0;string tmpString=null;object tmpObj=null;if(ds!=null && ds.Tables.Count>0 ){ for (int i=0; i<ds.Tables.Count;i++) { if (ds.Tables[i].Rows.Count>0) { for (int l=0; l<ds.Tables[i].Rows.Count) { for (int j=0; j<ds.Tables[i].Columns.Count) { if (ds.Tables[i].Rows[l][j] is int) { tmpInt=(int)ds.Tables[i].Rows[l][j]; } else if (ds.Tables[i].Rows[l][j] is string) { tmpString=(string)ds.Tables[i].Rows[l][j]; } else { tmpObj=ds.Tables[i].Rows[l][j]; } } } } }} 数据连接语句有多少种 这样的需求该如何实现?高分求代码示例 Timer控件的怪问题 做 winform 还是webform?大哥们给点意见 这几天脑子进水,关于怎么把webform.aspx.cs文件编译.dll的问题? 比如我的前台显示采购单号,如果有重复的,那么我想显示一个,其他的用--------来表示,不知道这个怎么做? .aspx+C#实现 请问这样可以实现吗?高手救命 求介绍网页开发软件 DataGrid设置行高 有谁知道以前VC,VB下的串行口控件(ActiveX MSCOMM32)到哪里去了?? 如何访问TCP/IP的网络层协议 问过好几次的问题了,没人能回答,望高手赐教呀!
ds.Tables[0].Rows.Count最好两个都使用
ds.tables[i].rows.count判断某个表是否有数据
{
}
bool flag=true; //用来判断DataTable中有无数据的标志。如果某个表中有数据,则flag=false。
for each (DataTable dt in ds)
{
if(dt.Rows.Count>0)
{
flag=false;
exit for;
}
}
if(!flag)
{
//有数据。
}
else
{
//无数据。
}
if(ds!=null && ds.Tables.Count>0 )
{
for (int i=0; i<ds.Tables.Count;i++)
{
if (ds.Tables[i].Rows.Count>0)
{
System.Console.Write("有数据!")
break;
}
}
}
(也把数据给取出来了)
int tmpInt=0;
string tmpString=null;
object tmpObj=null;if(ds!=null && ds.Tables.Count>0 )
{
for (int i=0; i<ds.Tables.Count;i++)
{
if (ds.Tables[i].Rows.Count>0)
{
for (int l=0; l<ds.Tables[i].Rows.Count)
{
for (int j=0; j<ds.Tables[i].Columns.Count)
{
if (ds.Tables[i].Rows[l][j] is int)
{
tmpInt=(int)ds.Tables[i].Rows[l][j];
}
else if (ds.Tables[i].Rows[l][j] is string)
{
tmpString=(string)ds.Tables[i].Rows[l][j];
}
else
{
tmpObj=ds.Tables[i].Rows[l][j];
}
}
}
}
}
}