Dim uname As String
uname = Accounts.value
Dim comStr As String = "UPDATE tbl_User SET UserName=@username1, [Password]=@password1, " &
"[Type]=@type1, Fname=@fname1, Mname=@mname1, Lname=@lname1, " &
"Address=@address1, City=@city1, State/Province=@State/Province1, " &
"Country=@country1, Phone=@phone1, Email=@email1 WHERE UserName=@value1"
Dim cmd = New OleDbCommand(comStr, con)
cmd.Parameters.AddWithValue("@username1", TextBox1.Text)
cmd.Parameters.AddWithValue("@password1", TextBox2.Text)
cmd.Parameters.AddWithValue("@type1", ComboBox1.SelectedText.ToString())
cmd.Parameters.AddWithValue("@Fname1", TextBox3.Text)
cmd.Parameters.AddWithValue("@Mname1", TextBox4.Text)
cmd.Parameters.AddWithValue("@Lname1", TextBox5.Text)
cmd.Parameters.AddWithValue("@address1", TextBox6.Text)
cmd.Parameters.AddWithValue("@city1", TextBox7.Text)
cmd.Parameters.AddWithValue("@State/Province1", TextBox8.Text)
cmd.Parameters.AddWithValue("@country1", TextBox9.Text)
cmd.Parameters.AddWithValue("@phone1", Convert.ToInt32(TextBox10.Text))
cmd.Parameters.AddWithValue("@email1", TextBox11.Text)
cmd.Parameters.AddWithValue("@value1", TextBox1.Text)
'Try
cmd.ExecuteNonQuery()
'Catch ex As Exception
'MessageBox.Show(ex.Message)
'Finally
con.Close()
'End Try
答案 0 :(得分:1)
根据评论中的注释,State/Province
不是列的好名称。除非名称是分隔符,否则大多数数据库系统的解析器都将拒绝/
斜杠。
听起来你发现使用方括号分隔符[State/Province]
将解决问题,但除非你有一个大型系统,否则最好重命名该字段,这样你就不必继续这样做了。改为使用下划线。