我正在尝试学习如何在我的 VB.net 程序中使用 MS Access。我正在练习学习如何使用 INSERT INTO 语句,但我不断收到错误消息。
这是我的代码:
Imports System.Data.OleDb
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myConnection As OleDbConnection
Dim DBpath As String = "C:\Documents and Settings\nordeen1\Desktop\Test.mdb"
Dim sConnectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & DBpath & ";Persist Security Info=True"
myConnection = New OleDbConnection(sConnectionString)
myConnection.Open()
Dim SQLstr As String
SQLstr = "INSERT INTO Test (Text, [Date], Number) VALUES ('testing', #2/6/1990#, 5)"
Dim cmd As New OleDbCommand(SQLstr, myConnection)
cmd.ExecuteNonQuery()
End Sub
End Class
我收到此错误“OleDbException 未处理。INSERT INTO 语句中的语法错误。” 在cmd.ExecuteNonQuery()
任何建议都非常感谢!谢谢!