首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

ds.Tables[0].Rows.Count 能查到0表 但count=0 sql语句没有关问题,求解释

2012-04-25 
ds.Tables[0].Rows.Count 能查到0表 但count0 sql语句没问题,求解释ds.Tables[0].Rows.Count 能查到0表

ds.Tables[0].Rows.Count 能查到0表 但count=0 sql语句没问题,求解释
ds.Tables[0].Rows.Count 能查到0表 但count=0 sql语句没问题,

[解决办法]
ds.Tables["0"].Rows.Count
[解决办法]
0是索引吧,自己看看是否有数据选出来
[解决办法]

探讨

string sql = "select * from View_TaskCourse where task_id=11";
DataSet ds = TaskSystem.DAL.DbHelper.Query(sql);
if (ds!=null&& ds.Tables[0].Rows.Count > 0)//这句不满足
表里有数据,sql语句写死了也是count=0

[解决办法]
确认db有数据,连接字符串都没问题的情况下,
从ds.Tables[0].Rows.Count这部分入手,查看ds.Tables 是否包含Table,Table是否包含Row,逐步进入TaskSystem.DAL.DbHelper.Query(sql)检查,调试

[解决办法]
探讨

string sql = "select * from View_TaskCourse where task_id=11";
DataSet ds = TaskSystem.DAL.DbHelper.Query(sql);
if (ds!=null&& ds.Tables[0].Rows.Count > 0)//这句不满足
表里有数据,sql语句写死了也是count=0

[解决办法]
探讨

public static DataSet Query(string SQLString)
{

using (SqlConnection connection = new SqlConnection(DbHelper.ConnectionString))
{
DataSet ds = ne……

热点排行