asp.net操作SQL数据库update的问题
最近在学asp.net,使用的是vb.net来创建asp.net项目
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connstr As String
connstr = "server=(local);uid=login;pwd=login;database=integration "
Dim conn As SqlClient.SqlConnection = New
System.Data.SqlClient.SqlConnection(connstr)
Try
conn.Open()
Label1.Text = "ok "
Catch ex As Exception
Label1.Text = "False "
End Try
Try
Dim comdstr As String
'comdstr = "insert into login_table values ( 'nilei ', '444 ', '1 ') "
comdstr = "update login_table set user= 'xiaoli ' where pwd= '444 ' "
Dim comd As SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(comdstr, conn)
comd.ExecuteNonQuery()
Label2.Text = "insert ok "
Catch ex As Exception
Label2.Text = ex.message ' "insert false "
Finally
conn.Close()
End Try
运行的时候提示错误:在关键字 'user ' 附近有语法错误。
请问我的代码有什么问题吗?
------解决方案--------------------User 是关键字
try ->
comdstr = "update login_table set [user]= 'xiaoli ' where [pwd]= '444 ' "
------解决方案-------------------- 哼哼,星星来抢裤衩的分
^_^