如数据库表是nb_JiaBanLog  要查找加班时间大于36小时的..假如数据库里面没有要的数据.提示"沒有數據"

解决方案 »

  1.   

    如果从代码中判断,看table.rows.count是否大雨0           .. 
    里面的table是代表什么意思..?
      

  2.   

    其实应该是dataset1.tables[0].rows.count
    代表的是查询返回的数据集的数据表结构
      

  3.   

    SqlConnection Con = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["Con"]);
    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();
      

  4.   


    ReGrid1.DataSource=ds.Tables["table2"].Rows.Count;--这里应该赋数据集,而你赋值的是数据记录的个数!!
    ReGrid1.DataBind();
    你的代码写错了!!!!!
    应该如此
    if(ds.Tables["table2"].Rows.Count>0)
    {
    ReGrid1.DataSource=ds.Tables["table2"];
    ReGrid1.DataBind();
    }
      

  5.   

    还有别忘记了最好要close connection!
    Con.Close();
      

  6.   

    谢谢 !!!jimu8130(火箭的未来在哪里?)
      

  7.   

    很简单啊,用数据集ds
    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();
    }
      

  8.   

    SqlConnection Con = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["Con"]);
    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();
    }
      

  9.   

    假如数据库里面没有要的数据.提示"沒有數據"
    ==========
    如果你使用GridView的话,直接设置 EmptyDataTemplate,此模板在没有数据的时候显示
      

  10.   

    你可以去lovecherry的cnblogs上面的blog多看看书籍看看wrox的asp.net 2.0入门
      

  11.   

    ds.tables[0].rows.count记录数,0就是没有记录你这个写错了.
    ReGrid1.DataSource=ds.Tables["table2"].Rows.Count;
    ReGrid1.DataBind();
    -----------------------------------------------------
    这样写:
    ReGrid1.DataSource = ds.Tables["table2"].DefaultView;
    ReGrid1.DataBind();
      

  12.   

    用dataReader 也行用它的对象的hasrows属性
      

  13.   

    declare @t1 table(a smalldatetime, b smalldatetime)
    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'
      

  14.   

    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();
    }
      

  15.   

    select count(*) from where ~~~~
    判断Datareader就可以了
      

  16.   

    if (read[1] == DBNull.Value)
                user.name = "";
    else
                user.name = red.GetString(1);