whateveragain
Programmer
I'm working with Visual Studio 2008, asp.net 3.5, MS Access 2007 on a Vista machine. I'm trying to insert data into an Access.mdb and am getting an error "Syntax error in INERT INTO statement." for the following code. Can anyone please tell me what is wrong? Thanks
Dim oleConn As New OleDb.OleDbConnection()
oleConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Joanne\Documents\Visual Studio 2008\WebSites\WebTesting\App_Data\whichdata.mdb;Mode=ReadWrite|Share Deny None;Persist Security Info=False"
Try
oleConn.Open()
Catch oleerr As Exception
MsgBox(oleerr.Message, "connection error!")
End Try
Dim olecomm As New OleDb.OleDbCommand()
olecomm.Connection = oleConn
olecomm.CommandText = "select * from whichdata"
Dim ds As New DataSet()
Dim da As New OleDb.OleDbDataAdapter()
da.SelectCommand = olecomm
Dim scb As New OleDb.OleDbCommandBuilder(da)
Try
da.Fill(ds, "whichdata")
Dim ndr = ds.Tables("whichdata").NewRow
ndr("sessionID") = Session.SessionID
ndr("mainmen") = "1"
ndr("whichdata1") = "1"
ndr("whichdata2") = "0"
ndr("whichdata3") = "0"
ds.Tables("whichdata").Rows.Add(ndr)
da.Update(ds, "whichdata")
Catch updex As Exception
MsgBox("Insert error")
MsgBox(updex.Message)
End Try
Dim oleConn As New OleDb.OleDbConnection()
oleConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Joanne\Documents\Visual Studio 2008\WebSites\WebTesting\App_Data\whichdata.mdb;Mode=ReadWrite|Share Deny None;Persist Security Info=False"
Try
oleConn.Open()
Catch oleerr As Exception
MsgBox(oleerr.Message, "connection error!")
End Try
Dim olecomm As New OleDb.OleDbCommand()
olecomm.Connection = oleConn
olecomm.CommandText = "select * from whichdata"
Dim ds As New DataSet()
Dim da As New OleDb.OleDbDataAdapter()
da.SelectCommand = olecomm
Dim scb As New OleDb.OleDbCommandBuilder(da)
Try
da.Fill(ds, "whichdata")
Dim ndr = ds.Tables("whichdata").NewRow
ndr("sessionID") = Session.SessionID
ndr("mainmen") = "1"
ndr("whichdata1") = "1"
ndr("whichdata2") = "0"
ndr("whichdata3") = "0"
ds.Tables("whichdata").Rows.Add(ndr)
da.Update(ds, "whichdata")
Catch updex As Exception
MsgBox("Insert error")
MsgBox(updex.Message)
End Try