IndexOutOfRangeException:找不到表0 [英] IndexOutOfRangeException: Cannot find table 0

查看:151
本文介绍了IndexOutOfRangeException:找不到表0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我的索引超出了范围异常,在我的代码下方请帮助我。

Hi

I got index out of range exception, below my code please help me.

SqlDataAdapter adp = new SqlDataAdapter(command);
adp.Fill(ds);
strReturn = Convert.ToString(ds.Tables[0].Rows[0][1]);

推荐答案





调试无法在visual studio 2010中运行。所以我无法调试我的代码。
Hi,

debug not working in visual studio 2010. so I can''t debug my code.






调试无法在visual studio 2010中运行。所以我无法调试我的代码。

adp.Fill(ds); //数据表检查

//System.IndexOutOfRangeException:找不到表0.

if(ds.Tables.Count> 0&& ds.Tables [ 0] .Rows.Count> 0&& ds.Tables [0] .Rows [0] [1]!= DBNull.Value)

{

strReturn = Convert.ToString(ds.Tables [0] .Rows [0] [1]);

}
Hi,

debug not working in visual studio 2010. so I can''t debug my code.
adp.Fill(ds); // Data table check
//System.IndexOutOfRangeException: Cannot find table 0.
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0][1] != DBNull.Value)
{
strReturn = Convert.ToString(ds.Tables[0].Rows[0][1]);
}


我认为问题是你的DataSet没有没有表[0]。
对于VS2010,可以调试
,如果你不可能,执行你的SQL查询并检查结果状态它会返回结果设置或不结帐。可能是你的SQL查询没有返回任何东西。因此,您的数据集没有数据,没有您尝试调用数据集表[0]的数据。它会自动通过错误IndexOutOfRangeException:找不到表0。
I think the problem is your DataSet doesn''t have a Table[0].
debug is possible for VS2010, if it''s not possible to you, Execute your SQL query and check the result status it''s return the result set or not checkout that. May be your SQL query doesn''t return any thing. So, your dataset doesn''t have a data , without data you try to call the dataset table[0]. It''s automatically through the error "IndexOutOfRangeException: Cannot find table 0".


这篇关于IndexOutOfRangeException:找不到表0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆