主题:SQL语法错,数据更新的问题,求教.
Dim s1 As Long = Val(Trim(TextBox1.Text))
Dim s2 As String = TextBox2.Text.Trim()
Dim s3 As String = TextBox3.Text.Trim()
Dim s4 As String = TextBox4.Text.Trim()
Dim s5 As String = TextBox5.Text.Trim()
Dim s6 As String = TextBox6.Text.Trim()
Dim s7 As String = TextBox7.Text.Trim()
Dim Da As New OleDbDataAdapter
cmd.Connection = conn
Da.SelectCommand = cmd
cmd.CommandText = "update biao1 set 用户名='" + s2 + "',密码='" + s3 + "',性别='" + s4 + "',年龄='" + s5 + "',电子邮件='" + s6 + "',手机号码='" + s7 + "' where ID = '" + s1 + "'"
conn.Open()
cmd.ExecuteNonQuery()
conn.Close() '更新数据
如把数据表ID改为文本是没有问题, s1为access 数据库biao1中自动编号,运行时出错,要怎么改?
Dim s2 As String = TextBox2.Text.Trim()
Dim s3 As String = TextBox3.Text.Trim()
Dim s4 As String = TextBox4.Text.Trim()
Dim s5 As String = TextBox5.Text.Trim()
Dim s6 As String = TextBox6.Text.Trim()
Dim s7 As String = TextBox7.Text.Trim()
Dim Da As New OleDbDataAdapter
cmd.Connection = conn
Da.SelectCommand = cmd
cmd.CommandText = "update biao1 set 用户名='" + s2 + "',密码='" + s3 + "',性别='" + s4 + "',年龄='" + s5 + "',电子邮件='" + s6 + "',手机号码='" + s7 + "' where ID = '" + s1 + "'"
conn.Open()
cmd.ExecuteNonQuery()
conn.Close() '更新数据
如把数据表ID改为文本是没有问题, s1为access 数据库biao1中自动编号,运行时出错,要怎么改?