I am trying to add a new record to data base using VB.net.
Here is my code:
Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient
Dim objConnection As New OleDb.OleDbConnection
objConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C:\Documents and Settings\ambarda\My Documents\db1.mdb;"
Dim ds As New DataSet
Dim sql As String = "SELECT * FROM Sheet1"
Dim objDataAdapter As New OleDb.OleDbDataAdapter(sql, objConnection)
objDataAdapter.Fill(ds, "Runsheet Info")
Dim cb As New OleDb.OleDbCommandBuilder(objDataAdapter)
Dim dsNewRow As DataRow = ds.Tables("Runsheet Info").NewRow()
dsNewRow.Item(1) = "a"
dsNewRow.Item(2) = PORECNUM.Text
dsNewRow.Item(3) = Devlist.Text
dsNewRow.Item(4) = "04/01/08"
dsNewRow.Item(5) = SORECNUM.Text
dsNewRow.Item(6) = "17887"
dsNewRow.Item(7) = "7"
dsNewRow.Item(8) = "Michigan NA"
dsNewRow.Item(9) = "xcr23414"
dsNewRow.Item(10) = "6544234"
dsNewRow.Item(11) = "b"
dsNewRow.Item(12) = "c"
dsNewRow.Item(13) = "d"
ds.Tables("Runsheet Info").Rows.Add(dsNewRow)
objDataAdapter.Update(ds, "Runsheet Info")
But I get errror: Syntax error in INSERT INTO statement. at last command(objDataAdapter.Update(ds, "Runsheet Info")
Any help would be appreciated.
Thanks in Advance,
Aditya