System.Data.OleDb.OleDbException附加信息:INSERT INTO语句中的语法错误

时间:2018-04-16 05:45:43

标签: vb.net ms-access access-vba

我收到此错误,无法解决此问题,请有人回复。

  

未处理的类型' System.Data.OleDb.OleDbException'   发生在System.Data.dll

中      

附加信息:INSERT INTO语句中的语法错误。

Dim cnnOLEDB As New OleDbConnection
    Dim cmdOLEDB As New OleDbCommand
    Dim cmdInsert As New OleDbCommand
    Dim cmdUpdate As New OleDbCommand
    Dim cmdDelete As New OleDbCommand
    Dim cmd As OleDbCommand

Dim cnn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\project\B-tech\FirstVBproject\LMSapp\LMSapp\Library2.accdb")




cnn.open()
Dim Bid, Bnmbr, bname, bauthor, Bdscptn, bcate, bpus, bprice, btype, byear, bpage, pcopy As String

    'Dim catename, catdes As String
    Dim insert As String
    Bnmbr = BNBRTXT.Text
    bname = TextBox1.Text
    bauthor = TextBox2.Text
    Bdscptn = TextBox3.Text
    bpus = TextBox4.Text
    bprice = TextBox5.Text
    byear = TextBox6.Text
    bpage = TextBox7.Text
    pcopy = TextBox8.Text


    'catdes = TextBox3.Text
    insert = "INSERT INTO book (BookNumber,Name,Author,Descraption,Publication,Price,Year,Pages,Copy) VALUES ('" & Bnmbr & "','" & bname & "','" & bauthor & "','" & Bdscptn & "','" & bpus & "','" & bprice & "','" & byear & "','" & bpage & "','" & pcopy & "'   )"
    cmd = New OleDbCommand(insert, cnn)
    cmdOLEDB = New OleDbCommand(insert, cnn)
    cnn.GetType()

    cmdOLEDB.ExecuteNonQuery()
    MsgBox("data inserted", MsgBoxStyle.Information)
    BNBRTXT.Text = ""
    TextBox1.Text = ""
    TextBox2.Text = ""
    TextBox3.Text = ""
    TextBox4.Text = ""
    TextBox5.Text = ""
    TextBox6.Text = ""
    TextBox7.Text = ""
    TextBox8.Text = ""


    cnn.close()

0 个答案:

没有答案