求助!!高手 NullReferenceException: 未将对象引用设置到对象的实例

rememberhai 2010-04-09 03:36:49

[NullReferenceException: 未将对象引用设置到对象的实例。]
com.DAL.NewsDAL.getTopSmallTitle(Int32 num, String lan) in F:\ShanXJZ921上传版本\英文\ShanXJZ\com.DAL\NewsDAL.cs:273
shownew.Page_Load(Object sender, EventArgs e) +85
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) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

网站挂上服务器后就 间断包这样的错。之前的测试都没问题。怎么回事?谢谢
...全文
197 33 打赏 收藏 转发到动态 举报
写回复
用AI写文章
33 条回复
切换为时间正序
请发表友善的回复…
发表回复
rememberhai 2010-04-09
  • 打赏
  • 举报
回复
现在的问题是所有的方法报错。 是方法找不到吧。
rememberhai 2010-04-09
  • 打赏
  • 举报
回复
[Quote=引用 31 楼 lost_painting 的回复:]

com.DAL.NewsDAL.getTopSmallTitle(Int32 num, String lan) in F:\ShanXJZ921上传版本\英文\ShanXJZ\com.DAL\NewsDAL.cs:273

很明确的告诉你出错的地方了.

慕白兄让lz贴出 getBusInfolist 的代码,lz不贴出来,我们来猜谜?
[/Quote]
不好意思。找了一天找晕了。

代码:
public List<BusinessInfo> getBusInfolist(BusinessInfo busInfo)
{
string sql = "select * from businessinfo where btype=@btype and lan=@lan";
SqlParameter[] par = new SqlParameter[]{
new SqlParameter("@btype",busInfo.btype),
new SqlParameter("@lan",busInfo.lan)
};
List<BusinessInfo> lb = new List<BusinessInfo>();
SqlDataReader reader = null;
try
{
reader = db.ExecuteReader(sql, par, CommandType.Text);
if (reader.HasRows)
{
while (reader.Read())
{
BusinessInfo b = new BusinessInfo();
b.id = Int32.Parse(reader["id"].ToString());
b.bcontext = reader["bcontext"].ToString();
b.bimage = reader["bimage"].ToString();
b.lan = reader["lan"].ToString();
lb.Add(b);
}
}
reader.Close();
}
catch (Exception e)
{
reader.Close();
return lb;
}
return lb;

}
鸭梨山大帝 2010-04-09
  • 打赏
  • 举报
回复
com.DAL.NewsDAL.getTopSmallTitle(Int32 num, String lan) in F:\ShanXJZ921上传版本\英文\ShanXJZ\com.DAL\NewsDAL.cs:273

很明确的告诉你出错的地方了.

慕白兄让lz贴出 getBusInfolist 的代码,lz不贴出来,我们来猜谜?
rememberhai 2010-04-09
  • 打赏
  • 举报
回复
我感觉问题不是出在没赋值上。 而是根本找不到方法。正在调。哪位遇到过相似问题。指点下。谢谢
zxn5211314 2010-04-09
  • 打赏
  • 举报
回复
你用ViewState了?
加油馒头 2010-04-09
  • 打赏
  • 举报
回复
大家一起来猜猜看 是什么原因吧
cpp2017 2010-04-09
  • 打赏
  • 举报
回复
看你加载dal的地方有没有成功.
qq175691524 2010-04-09
  • 打赏
  • 举报
回复
你应该多跟踪一下程序,可能是数据库的某些NULL值或者其它某些原因造成的
rememberhai 2010-04-09
  • 打赏
  • 举报
回复
我现在的感觉是所有dal类库里的方法都找不到。这个是问题关键。我怀疑路径。
cpp2017 2010-04-09
  • 打赏
  • 举报
回复
com.DAL.BusinessInfoDAL.getBusInfolist(BusinessInfo busInfo) in F:\ShanXJZ921上传
==>就在这附近找.

rememberhai 2010-04-09
  • 打赏
  • 举报
回复
[Quote=引用 22 楼 cpp2017 的回复:]

要从你的代码入手,如果就这个样子,没人帮你解决.
[/Quote]
谢谢楼上的兄弟。现在我是不知从哪里下手。代码本地不报错。挂上去之后都是类似上面的问题。郁闷啊。
cpp2017 2010-04-09
  • 打赏
  • 举报
回复
要从你的代码入手,如果就这个样子,没人帮你解决.
rememberhai 2010-04-09
  • 打赏
  • 举报
回复
在线等高手。谢谢。
rememberhai 2010-04-09
  • 打赏
  • 举报
回复
没有用到session谢谢
rememberhai 2010-04-09
  • 打赏
  • 举报
回复
本人不知从何下手了。放出200分希望高手指点下
echo0808 2010-04-09
  • 打赏
  • 举报
回复
你看看是不是session丢失
rememberhai 2010-04-09
  • 打赏
  • 举报
回复
大家可以登录网址
www.sxjinzuan.com
第一次点引导页会报错。但是在原页面上刷新一次的话就进去了。
请问谁知道吗》
rememberhai 2010-04-09
  • 打赏
  • 举报
回复
谢谢楼上各位。 代码调试时没有报任何错误。挂上去后出现的。
rememberhai 2010-04-09
  • 打赏
  • 举报
回复
和webconfig文件有关吗?
<connectionStrings>
<!--
<add name="conStr" connectionString="server=.;uid=sa;pwd=1111;database=jinzuan"/> -->
<add name="jinzuanConnectionString" connectionString="Data Source=203.158.16.73;Initial Catalog=jinzuan;Persist Security Info=True;User ID=jinzuan_f;Password=jinzuan" providerName="System.Data.SqlClient"/>
<add name="conStr" connectionString="Data Source=203.158.16.73;Initial Catalog=jinzuan;Persist Security Info=True;User ID=jinzuan_f;Password=jinzuan"/>
</connectionStrings>
sh_suyuelin 2010-04-09
  • 打赏
  • 举报
回复
BusinessInfoDAL.cs:87
调试调试。在添加值之类的地方加 判断是否==null
加载更多回复(13)

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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