本人碰到个问题很不解,来问下大家,代码如下:
int id = int.Parse(Session["ID"].ToString());
OleDbConnection Myconn = myconn.data_conn();
string tiajiao = "update name set brithday='" + tbxBrithday.Text + "',telephone='" + tbxTelphone.Text + "',note='" + tbxNote.Text+ "' where name_id=" +id;
OleDbCommand xiugai = new OleDbCommand(tiajiao, Myconn);
Myconn.Open();
xiugai.ExecuteNonQuery();
Myconn.Close();
运行总提示Update语句错误,但是我根据错误调试COPY出它的update语句运行,一点问题都没有,完全可以更新,请高手看看是怎么回事。谢谢~ 我截取出来的update语句是这样的:
UPDATE name SET brithday = '1984-05-22', telephone = '13325261245', [note] = '测试'
WHERE name_id = 101
int id = int.Parse(Session["ID"].ToString());
OleDbConnection Myconn = myconn.data_conn();
string tiajiao = "update name set brithday='" + tbxBrithday.Text + "',telephone='" + tbxTelphone.Text + "',note='" + tbxNote.Text+ "' where name_id=" +id;
OleDbCommand xiugai = new OleDbCommand(tiajiao, Myconn);
Myconn.Open();
xiugai.ExecuteNonQuery();
Myconn.Close();
运行总提示Update语句错误,但是我根据错误调试COPY出它的update语句运行,一点问题都没有,完全可以更新,请高手看看是怎么回事。谢谢~ 我截取出来的update语句是这样的:
UPDATE name SET brithday = '1984-05-22', telephone = '13325261245', [note] = '测试'
WHERE name_id = 101
WHERE [name_id] = 101 试下嘛,感觉NAME是关键字,不太确定。
WHERE [name_id] = 101 怎么你建表都用这些关键字呢..最好还是改改吧..
OleDbConnection Myconn = myconn.data_conn();
string tiajiao = "update name set brithday='" + tbxBrithday.Text + "',telephone='" + tbxTelphone.Text + "',note='" + tbxNote.Text+ "' where name_id=" +id;
OleDbCommand xiugai = new OleDbCommand(tiajiao, Myconn);
Myconn.Open(); //问题在这里
xiugai.ExecuteNonQuery();
这样
Myconn.Open();
OleDbCommand xiugai = new OleDbCommand(tiajiao, Myconn);
xiugai.ExecuteNonQuery();
改成
string tiajiao = "update [name] set brithday='" + tbxBrithday.Text + "',telephone='" + tbxTelphone.Text + "',[note]='" + tbxNote.Text+ "' where name_id=" +id; 发这么多帖-_-!