Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

At my wits end. Adding to Access Database.

$
0
0
Ok so I have this code. And I keep getting 'Syntax Error in INSERT INTO statement'. I've thrice checked it and I cant see any problem ;[


Dim sql As String
        Dim carsDa As OleDb.OleDbDataAdapter
        Dim carsDs As New DataSet

        con.Open()

        sql = "SELECT * FROM cars"
        carsDa = New OleDb.OleDbDataAdapter(sql, con)
        carsDa.Fill(carsDs, "Cars2")


        Dim cb As New OleDb.OleDbCommandBuilder(carsDa)
        Dim dsNewRow As DataRow
        dsNewRow = carsDs.Tables("Cars2").NewRow()
        dsNewRow.Item("customerID") = txtID.Text
        dsNewRow.Item("make") = txtMake.Text
        dsNewRow.Item("model") = txtModel.Text
        dsNewRow.Item("reg") = txtReg.Text
        dsNewRow.Item("year") = txtYear.Text
        dsNewRow.Item("enginesize") = txtEngine.Text
        carsDs.Tables("Cars2").Rows.Add(dsNewRow)

        carsDa.Update(carsDs, "Cars2")

        con.Close()

    End Sub



Any help would be fantastic!

Thanks

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>