By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,552 Members | 927 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,552 IT Pros & Developers. It's quick & easy.

Creating a new row and edit a row

P: n/a
I am banging my head agaisnt the wall, how do I add a new row and edit a
row?
Below is the code I am trying to use, it keeps throwing an exception abount
no insert command. Any ideas about this?
thnks
Dim mDBN As String = "C:\BNM.MDB"

Dim cCON As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mDBN
& ";Persist Security Info = False"

Dim mSQL As String = "SELECT * FROM Numbers"

Dim cn As New OleDb.OleDbConnection(cCON)

Dim DA As New OleDb.OleDbDataAdapter(mSQL, cn)

Dim DS As New DataSet

DA.FillSchema(DS, SchemaType.Source, "Numbers")

DA.Fill(DS, "Numbers")

Dim CBA As New OleDb.OleDbCommandBuilder(DA)

DA.UpdateCommand = CBA.GetUpdateCommand

Dim DT As New DataTable

DT = DS.Tables("Numbers")

Dim DR As DataRow

DR = DS.Tables("Numbers").NewRow

DR.BeginEdit()

DR("Number") = "OKAY DOO"

DR.EndEdit()

DS.Tables("Numbers").Rows.Add(DR)

DA.Update(DS, "Numbers")
Nov 16 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
heres the exact error message;
it happens as son as I call update
ErrorCode=-2147217900
Message="Syntax error in INSERT INTO statement."

"Warex" <Ig************@juno.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>I am banging my head agaisnt the wall, how do I add a new row and edit a
row?
Below is the code I am trying to use, it keeps throwing an exception
abount no insert command. Any ideas about this?
thnks
Dim mDBN As String = "C:\BNM.MDB"

Dim cCON As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
mDBN & ";Persist Security Info = False"

Dim mSQL As String = "SELECT * FROM Numbers"

Dim cn As New OleDb.OleDbConnection(cCON)

Dim DA As New OleDb.OleDbDataAdapter(mSQL, cn)

Dim DS As New DataSet

DA.FillSchema(DS, SchemaType.Source, "Numbers")

DA.Fill(DS, "Numbers")

Dim CBA As New OleDb.OleDbCommandBuilder(DA)

DA.UpdateCommand = CBA.GetUpdateCommand

Dim DT As New DataTable

DT = DS.Tables("Numbers")

Dim DR As DataRow

DR = DS.Tables("Numbers").NewRow

DR.BeginEdit()

DR("Number") = "OKAY DOO"

DR.EndEdit()

DS.Tables("Numbers").Rows.Add(DR)

DA.Update(DS, "Numbers")


Nov 16 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.