vb.net连接ACCESS数据库,提示insert into语句的语法错误,请高手帮忙解决
DimcnAsNewOleDbConnectioncn.ConnectionString=ConfigurationManager.ConnectionStrings("...
Dim cn As New OleDbConnection
cn.ConnectionString = ConfigurationManager.ConnectionStrings("access2003").ConnectionString
cn.Open()
Dim cmd As New OleDbCommand
Dim tsql As String
Dim sex As String
If RadioButton1.Checked Then
sex = "男"
Else
sex = "女"
End If
tsql = "insert into 家教需求信息(家长姓名,家庭地址,家庭电话,手机号,子女姓名,子女性别,就读学校,就读年级,辅导课目,辅导时间,对家教要求)values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & sex & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox9.Text & "','" & TextBox10.Text & "',)"
cmd = New OleDbCommand(tsql, cn)
''cmd.CommandType = CommandType.Text
''cmd.CommandText = tsql
cmd.ExecuteNonQuery()
Response.Write("<script language='javascript'>alert('成功添加用户!');</script>")
cn.Close() 展开
cn.ConnectionString = ConfigurationManager.ConnectionStrings("access2003").ConnectionString
cn.Open()
Dim cmd As New OleDbCommand
Dim tsql As String
Dim sex As String
If RadioButton1.Checked Then
sex = "男"
Else
sex = "女"
End If
tsql = "insert into 家教需求信息(家长姓名,家庭地址,家庭电话,手机号,子女姓名,子女性别,就读学校,就读年级,辅导课目,辅导时间,对家教要求)values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & sex & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox9.Text & "','" & TextBox10.Text & "',)"
cmd = New OleDbCommand(tsql, cn)
''cmd.CommandType = CommandType.Text
''cmd.CommandText = tsql
cmd.ExecuteNonQuery()
Response.Write("<script language='javascript'>alert('成功添加用户!');</script>")
cn.Close() 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询