日期:2014-05-17  浏览次数:20409 次

未将对象引用设置到对象的实例
语法
dtcontract = (new BContract()).GetList(" where con_id in (select top 5 con_id from ContractLists where   CON_Site_Audit=2 and CON_Status>=1  and artid not in('') and  CON_ID in ( select distinct cd_contract from ContractDistributeList where cd_staff in" + ibd.getValue("select s_id from Stafflist where  D_Address like '" + ibd.GetModel(D_ParentID).D_Address + "%'") + ")   and CON_Status!=12 Order By CON_Order desc )");

报错

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

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

源错误: 

执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。  

堆栈跟踪: 


[NullReferenceException: 未将对象引用设置到对象的实例。]
   OA.manage.bindcontract(Int32 num) in E:\aspnetproject\一网科技oa\OA\OA\manage.aspx.cs:281
   OA.manage.Page_Load(Object sender, EventArgs e) in E:\aspnetproject\一网科技oa\OA\OA\manage.aspx.cs:47
   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.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

 


--------------------------------------------
版本信息: Microsoft .NET Framework 版本:2.0.50727.5466; ASP.NET 版本:2.0.50727.5456 



这事为何?
------解决方案--------------------
dtcontract = (new BContract()).GetList(" where con_id in (select top 5 con_id from ContractLists where   CON_Site_Audit=2 and CON_Status>=1  and artid not in('') and  CON_ID in ( select distinct cd_contract from ContractDistributeList where cd_staff in" + ibd.getValue("select s_id from Stafflist where  D_Address like '" + ibd.GetModel(D_ParentID).D_Address + "%'") + ")   and CON_Status!=12 Order By CON_Order desc )");

看的头晕   你把方法都拆开执行

有一个返回值是null   所以就报错