主题:这是怎么回事:编译器错误信息: 不可访问“chat.detail.dr”,因为它受保护级别限制
“/chat”应用程序中的服务器错误。
--------------------------------------------------------------------------------
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误信息: CS0122: 不可访问“chat.detail.dr”,因为它受保护级别限制
源错误:
行 46: <TD style="HEIGHT: 25px" class="p3">
行 47: <br>
行 48: <%=dr["biaoti"]%>
行 49: <FONT face="宋体"></FONT>
行 50: </TD>
这里是页面detail.aspx.cs的代码:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace chat
{
/// <summary>
/// detail 的摘要说明。
/// </summary>
///
public class detail : System.Web.UI.Page
{
DataSet ds;
DataRow dr;
String newsid;
void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
SqlConnection MyConnection;
String strCon;
newsid=Request.Params["id"];
MyConnection=new SqlConnection("server=localhost;database=news;uid=sa;pwd='818'");
MyConnection.Open();
String strCom="select biaoti,zhaizi,neirong,img,counter,shijian from news where id="+newsid;
ds=new DataSet();
SqlDataAdapter myCommand=new SqlDataAdapter(strCom,MyConnection);
myCommand.Fill(ds,"news");
dr=ds.Tables["news"].Rows[0];
strCon="select counter from news where id="+newsid;
SqlCommand myCommand2=new SqlCommand(strCon,MyConnection);
SqlDataReader reader=myCommand2.ExecuteReader();
reader.Read();
int i=reader.GetInt32(0);
i++;
reader.Close();
strCon="UPDATE news SET counter="+i.ToString()+" WHERE(id="+newsid+")";
myCommand2.CommandText=strCon;
myCommand2.ExecuteNonQuery();
MyConnection.Close();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
--------------------------------------------------------------------------------
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误信息: CS0122: 不可访问“chat.detail.dr”,因为它受保护级别限制
源错误:
行 46: <TD style="HEIGHT: 25px" class="p3">
行 47: <br>
行 48: <%=dr["biaoti"]%>
行 49: <FONT face="宋体"></FONT>
行 50: </TD>
这里是页面detail.aspx.cs的代码:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace chat
{
/// <summary>
/// detail 的摘要说明。
/// </summary>
///
public class detail : System.Web.UI.Page
{
DataSet ds;
DataRow dr;
String newsid;
void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
SqlConnection MyConnection;
String strCon;
newsid=Request.Params["id"];
MyConnection=new SqlConnection("server=localhost;database=news;uid=sa;pwd='818'");
MyConnection.Open();
String strCom="select biaoti,zhaizi,neirong,img,counter,shijian from news where id="+newsid;
ds=new DataSet();
SqlDataAdapter myCommand=new SqlDataAdapter(strCom,MyConnection);
myCommand.Fill(ds,"news");
dr=ds.Tables["news"].Rows[0];
strCon="select counter from news where id="+newsid;
SqlCommand myCommand2=new SqlCommand(strCon,MyConnection);
SqlDataReader reader=myCommand2.ExecuteReader();
reader.Read();
int i=reader.GetInt32(0);
i++;
reader.Close();
strCon="UPDATE news SET counter="+i.ToString()+" WHERE(id="+newsid+")";
myCommand2.CommandText=strCon;
myCommand2.ExecuteNonQuery();
MyConnection.Close();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}

您所在位置: