再发一帖,数据库更新问题!
private void Page_Load(object sender, System.EventArgs e)
{
if (Request.Cookies["Admin_Name"].Value==null)
{
Response.Redirect("Admin_Login.aspx");
}
else
{
sql="Select * from tb_CoInfo where Info_Id=1";
OleDbCommand cmd=new OleDbCommand(sql,conn);
//cmd.Connection();
cmd.Connection.Open();
OleDbDataReader dr=cmd.ExecuteReader();
dr.Read();
txtCoInfo.Text=dr["Co_Info"].ToString();
cmd.Connection.Close();
cmd.Dispose();
}
}
private void btnRest_Click(object sender, System.EventArgs e)
{
txtCoInfo.Text="";
}
private void btnUpdate_Click(object sender, System.EventArgs e)
{ string Co_Info=txtCoInfo.Text.ToString();
sql="update tb_CoInfo set Co_Info='"+Co_Info+"' where Id=1";
OleDbCommand cmdUp=new OleDbCommand(sql,conn);
cmdUp.Connection.Open();
cmdUp.ExecuteNonQuery();
cmdUp.Connection.Close();
cmdUp.Dispose();
}
段语句有问题吗?为什么无法实现更新呢?而且没有任何错误提示数据是access 其中Co_Info是备注型,Info_Id是数字型,变量Co_Info是string型,,我感觉btnUpdate_Click根本就没执行。。请大家帮忙了。上次发的帖子没结果