There is no row at position 0.盼望过路大虾搭救!
时间:2011-12-17
来源:互联网
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();
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();
作者: cbb_a 发布时间: 2011-12-17
23行的问题,断点调试看看select查询有没有查到数据
作者: zh6335901 发布时间: 2011-12-17
你查询出的表里没有记录
所以取值时要判断一下
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 = "";
}
所以取值时要判断一下
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 = "";
}
作者: gxingmin 发布时间: 2011-12-17
if(dt.Rows.Count>0)
需要判断阿
需要判断阿
作者: ximenwuji 发布时间: 2011-12-17
立马就解决啦!(*^__^*) 嘻嘻……!谢谢啦!
作者: cbb_a 发布时间: 2011-12-17
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28