我正在尝试通过www.example.com Windows窗体应用程序将数据插入MS Access数据库VB.net
执行此代码时
Dim con As New OleDbConnection(CS)
Dim cmd As New OleDbCommand("INSERT INTO Ports ([PortNumber] , [DistributionBoardLocation] , [DistributionBoardSubLocation] , [PortLocation] , [PortSubLocation] , [PortDevice] , [POE]) VALUES('" & nudPortNumber.Value & "', '" & txtDBLocation.Text & "', '" & txtDBSubLocation.Text & "' , '" & txtPortLocation.Text & "' , '" & txtPortSubLocation.Text & "' , '" & txtPortDevice.Text & "' , '" & chPOE.Checked & "'", con)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
MsgBox("New Port Has Been Created")
我收到此错误消息-
System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement
请帮帮忙
谢谢你,雅各布
1条答案
按热度按时间xzlaal3s1#
您将每个值都作为文本插入,但实际情况可能并非如此。请进行调整,例如端口号: