我的INSERT语句有语法错误,但我不知道在哪里。错误消息显示第13行有,但我无法看到问题。有人可以帮忙吗?
Imports System.Data.OleDb
Public Class Form2
Dim cnn As OleDbConnection
Dim cmd As New OleDbCommand
Dim sqlstr As String
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Try
cnn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\Library.accdb;")
cnn.Open()
sqlstr = "INSERT INTO Users (ID,User_Name,Password) VALUES ('" & txtID.Text & "','" & txtUser.Text & "','" & txtPassword.Text & "')"
cmd = New OleDbCommand(sqlstr, cnn)
cmd.ExecuteNonQuery()
cnn.Close()
MsgBox("User saved.")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
结束班