IndexOutOfRangeException:找不到表0

编程入门 行业动态 更新时间:2024-10-18 10:29:16
本文介绍了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

本文发布于:2023-07-04 17:14:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1026940.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:找不到   IndexOutOfRangeException

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!