如数据库表是nb_JiaBanLog 要查找加班时间大于36小时的..假如数据库里面没有要的数据.提示"沒有數據"
解决方案 »
- URL参数加密问题
- Gridview中的textbox显示浮动提示
- <td class="style21" onmouseover="message1" onmouseout="message1" >为什么不执行事件呢??
- 存储过程有无必要使用在ado.net中使用SqlTransaction?
- IIS下部署传真服务 报拒绝访问错误 权限问题
- 一个关于利用showmodaldialog弹出新页面,输入数据后返回原页面的问题.在线急等,百分相送!!
- 如何用c#实现跟着网页滚动的两边广告条!
- 跪求c#的文章发布系统+论坛
- C#
- 入门问题
- 请大家帮我把这个程序的逻辑检查一下,到底是哪里出错了?我实在想不通,
- URL重写,怎么让传过去的id转换成用户名后,在重写URL(顶者有分)
里面的table是代表什么意思..?
代表的是查询返回的数据集的数据表结构
Con.Open();
SqlCommand cmd = new SqlCommand("select WorkId,[name],FactTotal from nb_JiaBanLog where facttotal > 36",Con);
SqlDataAdapter da=new SqlDataAdapter(cmd);
DataSet ds=new DataSet();
da.Fill(ds,"table2");
ReGrid1.DataSource=ds.Tables["table2"].Rows.Count;
ReGrid1.DataBind();
ReGrid1.DataSource=ds.Tables["table2"].Rows.Count;--这里应该赋数据集,而你赋值的是数据记录的个数!!
ReGrid1.DataBind();
你的代码写错了!!!!!
应该如此
if(ds.Tables["table2"].Rows.Count>0)
{
ReGrid1.DataSource=ds.Tables["table2"];
ReGrid1.DataBind();
}
Con.Close();
sql语句为select * from [tablename] where [时间字段]>36
得出ds后,写:
int num=ds.tables[0].rows.count;
if(num==0)
{
response.write("没有数据");
}
else
{
dg.datasource=ds;
dg.databind();
}
Con.Open();
SqlCommand cmd = new SqlCommand("select WorkId,[name],FactTotal from nb_JiaBanLog where facttotal > 36",Con);
SqlDataAdapter da=new SqlDataAdapter(cmd);
DataSet ds=new DataSet();
da.Fill(ds);
if(ds!=null&&ds.Tables[0].Rows.Count>0)
{
ReGrid1.DataSource = ds.Tables[0].DefaultView;
ReGrid1.DataBind();
}
==========
如果你使用GridView的话,直接设置 EmptyDataTemplate,此模板在没有数据的时候显示
ReGrid1.DataSource=ds.Tables["table2"].Rows.Count;
ReGrid1.DataBind();
-----------------------------------------------------
这样写:
ReGrid1.DataSource = ds.Tables["table2"].DefaultView;
ReGrid1.DataBind();
insert @t1
select '2007-6-18 14:00:00','2007-6-18 15:00:00' union all
select '2007-6-18 14:00:00','2007-6-18 14:00:00' union all
select '2007-6-18 14:00:00','2007-6-18 14:00:00' union all
select '2007-6-18 14:00:00','2007-6-18 14:00:00' declare @count int;
set @count=(select count(datediff(hh,a,b)) as result from @t1 where datediff(hh,a,b)>0) ;
if(@count>0) print 'yes';
else print 'no'
得出ds后,写:
int num=ds.tables[0].rows.count;
if(num==0)
{
response.write("没有数据");
}
else
{
dg.datasource=ds;
dg.databind();
}
判断Datareader就可以了
user.name = "";
else
user.name = red.GetString(1);