异常详细信息:system.nullreferenceexception:对象引用未设置为对象的实例。 [英] Exception details: system.nullreferenceexception: object reference not set to an instance of an object.

查看:150
本文介绍了异常详细信息:system.nullreferenceexception:对象引用未设置为对象的实例。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Quote:

描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。



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

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.NullReferenceException: Object reference not set to an instance of an object.





我尝试过:





What I have tried:

  {
Line 29: 
Line 30:             CDT = Cadapter.SELECT_SEARCH_COMPANY(Session["JOBCATE"].ToString(), Session["QUALI"].ToString(), Session["skill"].ToString());
Line 31:             Session["CID"] = CDT.Rows[0]["CID"].ToString();
Line 32:             if (CDT.Rows.Count == 0)

推荐答案





未引用数据表时发生此错误。

在您的代码中,发生错误是因为数据表CDT为空并且您尝试读取它。

Hi,

This error occurs when the datatable is not referenced.
In your code, the error occurred because the datatable CDT is null and you tried to read it.
Session["CID"] = CDT.Rows[0]["CID"].ToString();





修复此错误。



To fix this error.

 CDT = Cadapter.SELECT_SEARCH_COMPANY(Session["JOBCATE"].ToString(),Session["QUALI"].ToString(), Session["skill"].ToString());
if(CDT != null)
{
   if(CDT.Rows.Count > 0)
   {
       Session["CID"] = CDT.Rows[0]["CID"].ToString();
   }
   else 
   {
       //your code
   }
}


这篇关于异常详细信息:system.nullreferenceexception:对象引用未设置为对象的实例。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆