string connstring = WebConfigurationManager.ConnectionStrings["connstring"].ToString();
OleDbConnection con = new OleDbConnection(connstring);
con.Open();
string sql = "update news set newsID=" + newsid.Text.ToString() + ",Title=" + Title.Text.ToString() + ",Author=" + Author.Text.ToString() + ",Detail="+Detail.Text.ToString() + " where newsID="+Session["newsid"].ToString()+" ";//用where指定修改那一条信息
OleDbCommand cmd = new OleDbCommand(sql, con);
cmd.ExecuteNonQuery();
con.Close();
Response.Write("<script>alert('修改成功!')</script>");
其中newsID是数字型,其余的都是文本类型,改了半天没改出来,想知道sql语句错在什么地方
OleDbConnection con = new OleDbConnection(connstring);
con.Open();
string sql = "update news set newsID=" + newsid.Text.ToString() + ",Title=" + Title.Text.ToString() + ",Author=" + Author.Text.ToString() + ",Detail="+Detail.Text.ToString() + " where newsID="+Session["newsid"].ToString()+" ";//用where指定修改那一条信息
OleDbCommand cmd = new OleDbCommand(sql, con);
cmd.ExecuteNonQuery();
con.Close();
Response.Write("<script>alert('修改成功!')</script>");
其中newsID是数字型,其余的都是文本类型,改了半天没改出来,想知道sql语句错在什么地方
---
改成string sql = "update news set newsID=" + newsid.Text.ToString() + ",Title='" + Title.Text.ToString() + "',Author='" + Author.Text.ToString() + "',Detail='"+Detail.Text.ToString() + "' where newsID="+Session["newsid"].ToString()+" ";//用where指定修改那一条信息
[/Quote
结果一样