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();
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();
所以取值时要判断一下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 = "";
}
需要判断阿