网站是当连着刷新或者打开一定次数后就出现下面的错误,但过段时间后又正常了。请问是什么原因啊?非常感谢
未将对象引用设置到对象的实例
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。
源错误:
行 23: ForNotice.Text += "<tr>";
行 24: tDr = common.GetTopRec("[Notices]", 5, "[N_ID]"

;
行 25: while (tDr.Read())
行 26: {
行 27: ForNotice.Text += "<td align='right' width='10%'><img src='images/pic2.jpg'/></td><td align='left'><a href='ShowNotices.aspx?ID=" + tDr["N_ID"].ToString() + "' style='color: #d6d6cc; font-size:11pt' target='_blank'>" + tDr["N_Title"].ToString() + "</a> <font color='#d6d6cc' size='2pt'>" + tDr["N_Date"].ToString() + "</font><br></td></tr>";
源文件: e:webmanagementonlineIndex.aspx.cs 行: 25
堆栈跟踪:
[NullReferenceException: 未将对象引用设置到对象的实例。]
Index.Page_Load(Object sender, EventArgs e) in e:webmanagementonlineIndex.aspx.cs:25
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
代码如下:
<add name="Conn" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=H:DoingonlineApp_DataEBDataBase.mdb"/>
public OleDbConnection Con = new OleDbConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
public OleDbCommand Cmd = null;
private static string FileName = "H:\Doing\online\Logs\Logs.txt";
public string ErrorInfo = "";
public void Open()
{
if (Con.State == ConnectionState.Closed)
{
try
{
Con.Open();
}
catch (Exception ex)
{
SqlHelper.CreatErrorMessage(ex.Message);
}
finally
{
}
}
}
public void Close()
{
if (Con != null)
{
if (Con.State == ConnectionState.Open)
{
Con.Close();
}
}
}
public void Action(string CmdLine,out int nResult)
{
nResult = -1;
Cmd = new OleDbCommand(CmdLine, Con);
Open();
try
{
CreatErrorMessage(CmdLine);
nResult = Cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
ErrorInfo = ex.Message;
CreatErrorMessage(ErrorInfo);
}
finally
{
Close();
}
}
显示时:
Common common = new Common();
OleDbDataReader tDr = null;
ForNotice.Text += "<font color='#d6d6cc'><div align=center>最新通知</div></font>";
ForNotice.Text += "<table width='100%' border='0'>";
ForNotice.Text += "<tr>";
tDr = common.GetTopRec("[Notices]", 5, "[N_ID]");
while (tDr.Read())
{
ForNotice.Text += "<td align='right' width='10%'><img src='images/pic2.jpg'/></td><td align='left'><a href='ShowNotices.aspx?ID=" + tDr["N_ID"].ToString() + "' style='color: #d6d6cc; font-size:11pt' target='_blank'>" + tDr["N_Title"].ToString() + "</a> <font color='#d6d6cc' size='2pt'>" + tDr["N_Date"].ToString() + "</font><br></td></tr>";
}
ForNotice.Text += "</table>";
[
本帖最后由 tnttmd 于 2008-4-28 22:12 编辑 ]