SqlConnection conn = new SqlConnection();

来源:百度知道 编辑:UC知道 时间:2024/06/14 22:59:05
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "server=(local);uid=sa;pwd=sa;database=QZTGLSYS";
conn.Open();
string seSQL = "update 记录内容表 set 日期= " + "'" + this.dtpriqi1.Text + "'" + ",记事人= " + "'" + this.txtjishir1.Text + "'" + "," +
"记事内容= " + "'" + this.txtjishilolong.Text + "'" + ",备注= " + "'" + this.txtbeizhu1.Text + "'" + "," +
"where 日期= " + "'" + this.dtpriqi1 + "'" + " and 记事人= " + "'" + this.txtjishir1 + "'";
SqlCommand cmd = new SqlCommand();
SqlDataAdapter adr = new SqlDataAdapter();
cmd.Connect

1.SqlDataAdapter adr = new SqlDataAdapter(); //这句多余.

2.where 后面跟的两个参数this.dtpriqi1和this.txtjishir1没有加属性Text;

你的连接字符串写的实在不敢恭维..我给你整理了一下:

string seSQL = "update 记录内容表 set 日期='"+this.dtpriqi1.Text+"',记事人='"+this.txtjishir1.Text+"',记事内容='"+this.txtjishilolong.Text+"',备注='"+this.txtbeizhu1.Text+"', where 日期='"+ this.dtpriqi1.Text+"' and 记事人='"+this.txtjishir1.Text+"'";

提个建议,最好不要连接字符串,否则会有SQL注入的危险

你可以在执行语句之前,输出SQL语句来看是不是你要的!!还可以放到sqlserver 里去测试 !!! 这样问题一般来说很快就解决了