the code is below.
the system said me that the insert into sql syntax error
any solutions?

Dim dbProvider As String
    Dim dbSource As String
    Dim constr As New OleDb.OleDbConnection
    Dim sql As String
    Dim ds As New DataSet
    Dim da As OleDb.OleDbDataAdapter

form load code:
        dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
        dbSource = "Data Source = pj.mdb"
        constr.ConnectionString = dbProvider & dbSource
        sql = "select * from information"
        da = New OleDb.OleDbDataAdapter(sql, constr)
        da.Fill(ds, "bking")

button click event :
        Dim cb As New OleDb.OleDbCommandBuilder(da)
        Dim dsNewRow As DataRow
        dsNewRow = ds.Tables("bking").NewRow()
        dsNewRow.Item(0) = "1231231"
        da.Update(ds, "bking")
        MsgBox("New Record added to the Database")

Edited 5 Years Ago by Nick Evan: Added [CODE] tags


Add Oledbcommand and Oledbconnection in Your project and create connection and in below coding do changes as requied and it will work.

Dim ROW As DataRow
        Dim Cmd As New OleDb.OleDbCommand

        With Cmd
            .CommandText = "INSERT INTO [TableName] (VERSION, SMASK, EQP, FCAP, JCAP, YCAP)  VALUES  ('" & VERSION.Text & "', '" & SMASK.Text & "', '" & EQP.Text & "','" & FCAP.Text & "', '" & JCAP.Text & "', '" & YCAP.Text & "')"
            .CommandType = CommandType.Text
            .Connection = Me.OleDbConnection1
        End With


Edited 5 Years Ago by Nick Evan: Added [CODE] tags. Learn to use them yourself please.

This article has been dead for over six months. Start a new discussion instead.