日期:2014-05-18  浏览次数:20883 次

请高手帮忙啊,列名 'Xinwenneirong1' 无效
运行就说列名 'Xinwenneirong1' 无效


private void Page_Load(object sender, System.EventArgs e)

{
if(!IsPostBack)
{
if(Request.QueryString["ID"]!=null&& Request.QueryString["ID"].Length>0)
ID=Request.QueryString["ID"];

string connectionString=ConfigurationSettings.AppSettings["connectionString"];
SqlConnection con=new SqlConnection(connectionString);
con.Open();

string Sql="select Title,Adduser,Addtime from S_News where ID=" +ID;
SqlCommand com=new SqlCommand(Sql,con);
SqlDataReader reader=com.ExecuteReader(); if(reader.Read())
{
lTitle.Text=reader["Title"].ToString();
lAdduser.Text=reader["Adduser"].ToString();
lAddtime.Text=reader["Addtime"].ToString();
}
else
{
lresult.Text="没有找到相应的信息";
}
reader.Close();
con.Close();
}
}


------解决方案--------------------
Sql="select Title,Adduser,Addtime from S_News where ID=" +ID; 
看看你取得的id是什么

------解决方案--------------------
先确认是不是有'Xinwenneirong1'这个字段。
 
------解决方案--------------------
貌似错误不在你的这段代码里面
------解决方案--------------------
应该是你从数据库中取的数据和列名有冲突,或者没有这个列