System.IndexOutOfRangeException:找不到表0

时间:2011-09-09 17:44:15

标签: asp.net

我很快就遇到了这个问题,我无法找到解决方案 我收到了这个错误:

  

'System.IndexOutOfRangeException:找不到表0'在第3行:

if (Session["value"] != null)
                {
                  **ds = proxy.GetId(Session["value "].ToString());**
                    if (ds!= null)
                    {
                        if (ds.Tables.Count == 0)
                        {
                            Response.Redirect("Timeout.aspx");
                        }
                        else
                        {
                            if (ds.Tables.Count > 0)
                            {
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    string Id = ds.Tables[0].Rows[0]["id"].ToString().Trim();
                                    if (Id.Trim() == "0")
                                    {
                                        Session["ID"] = "ID NOT CREATED";
                                        ds = proxy.Getid(Session["value "].ToString());
                                    }
                                }
                            }
                        }
                    }

理想情况下,只有从存储过程返回的值,因此错误不应出现在第3行,因为我将数据集'ds'的所有检查放在下面的代码中。请求帮助我...

1 个答案:

答案 0 :(得分:0)

您是否已检查函数GetId以查找错误的可能原因,或者您转换为字符串的会话变量是否具有值?如果您在尝试将会话var变为字符串时尚未初始化,我可以看到您收到该错误。

相关问题