现在的位置: 首页 > 综合 > 正文

System.IndexOutOfRangeException: 无法找到表 0解决办法

2018年02月15日 ⁄ 综合 ⁄ 共 224字 ⁄ 字号 评论关闭

错误提示:System.IndexOutOfRangeException: 无法找到表 0

一般出现这种情况就是没有查出来数据,需要加个判断

其中需要的判断如下

if(ds == null)//ds为空

if(ds.Tables.Count == 0)//ds中没有表  ds.talbe[0]错误时无法找到表0

if(ds.Tables.Count == 1 && ds.Tables[0].Rows.Count == 0)//ds中的表没有数据

希望能对碰到这类错误的童鞋们有所帮助

抱歉!评论已关闭.