PC Review Forums Newsgroups Microsoft DotNet Microsoft VB .NET Creating a new row and edit a row

Reply

Creating a new row and edit a row

 
Thread Tools Rate Thread
Old 16-11-2006, 01:31 AM   #1
Warex
Guest
 
Posts: n/a
Default Creating a new row and edit a row


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")


  Reply With Quote
Old 16-11-2006, 01:41 AM   #2
Warex
Guest
 
Posts: n/a
Default Re: Creating a new row and edit a row

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

"Warex" <Igiveitallaway@juno.com> wrote in message
news:%23d9pt7RCHHA.3396@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")
>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off