发生错误:未将对象引用设置到对象的实例

HHY_haii 2014-03-29 11:07:13
protected void Page_Load(object sender, EventArgs e)
{



if (!IsPostBack)
{
yonghuming.Items.Add("请选择");
addxiala("yonghuzhuce", "yonghuming", "kehubianhao");
xlm.Items.Add("请选择");
addxiala3("xianlu", "xlm", "ddd");

//chem.Items.Add("请选择");
//addxiala1("clxinxi", "chem", "zt");

string sql;

sql = "select * from chedd where ID=" + Request["ID"].ToString().Trim();

getdata(sql);

}
}

未将对象引用设置到对象的实例。
说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。

源错误:


行 29: string sql;
行 30:
行 31: sql = "select * from chedd where ID=" + Request["ID"].ToString().Trim();
行 32:
行 33: getdata(sql);

堆栈跟踪:


[NullReferenceException: 未将对象引用设置到对象的实例。]
chedd_updt.Page_Load(Object sender, EventArgs e) in f:\陈艳莲\cldd\chedd_updt.aspx.cs:31
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207



...全文
144 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
查询语句按照ID降序排列即可 select * from table order by id desc
HHY_haii 2014-03-30
  • 打赏
  • 举报
回复
引用 1 楼 Return_false 的回复:
这个不是已经说过了吗,判断Request["ID"]为空

知道怎么改变这个的顺序吗?第一个在最后,第二个在倒数第二个,,,,,

HHY_haii 2014-03-30
  • 打赏
  • 举报
回复
引用 1 楼 Return_false 的回复:
这个不是已经说过了吗,判断Request["ID"]为空
我发了一个帖子,然后怎么都找不到,以为没发成功,所以又发了一遍,谢谢你的帮忙咯
  • 打赏
  • 举报
回复
这个不是已经说过了吗,判断Request["ID"]为空

87,903

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧