There is no row at position 0. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IndexOutOfRangeException: There is no row at position 0.Source Error: 
Line 22:             }
Line 23:             DataTable dt = Sqlbase.ExecuteTable(CommandType.Text, "select * from book where id=" + Convert.ToInt32(Request["id"]), null);
Line 24:             lbname.Text=dt.Rows[0]["name"].ToString();
Line 25:             lbkit.Text = dt.Rows[0]["kit"].ToString();
Line 26:             lborther.Text = dt.Rows[0]["author"].ToString();
 

解决方案 »

  1.   

    23行的问题,断点调试看看select查询有没有查到数据
      

  2.   

    你查询出的表里没有记录
    所以取值时要判断一下DataTable dt = Sqlbase.ExecuteTable(CommandType.Text, "select * from book where id=" + Convert.ToInt32(Request["id"]), null);
    if(dt.Rows.Count>0)
    {
       lbname.Text=dt.Rows[0]["name"].ToString();
       lbkit.Text = dt.Rows[0]["kit"].ToString();
       lborther.Text = dt.Rows[0]["author"].ToString();
    }
    else

       lbname.Text="";
       lbkit.Text ="";
       lborther.Text = "";
    }
      

  3.   

    if(dt.Rows.Count>0)
    需要判断阿