日期:2014-05-18  浏览次数:20724 次

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……