hi,
This is not something very complicated that i am trying to do. All i am
doing is put data in a datagrid and using a
customised Insert query to insert a row. The data does appear on the
datagrid, but when i insert a new row and use da.update(ds,dt ) it gives
this error.
The same thing works fine if i use oledbQueryBuild er instead of my own
InsertCommand, but querybuilder does not usually fulfill the purpose always.
I created a very simplified AccessDatabase with just a table having two
columns.
Please see the code below and i would appreciate ur suggestions.
TIA
irfan
Dim con As New OleDbConnection (ConnString)
da = New OleDbDataAdapte r
ds = New DataSet()
Dim cmd As New OleDbCommand("S ELECT id,name from table1", con)
da.SelectComman d = cmd
da.Fill(ds, "mytable")
'create an insert command
Dim cmdInsert As New OleDbCommand( _
"INSERT INTO Table1( id, Name) VALUES (?,?)", con)
'create parameter
Dim par1 As New OleDbParameter( "id", OleDbType.LongV arWChar)
Dim par2 As New OleDbParameter( "Name", OleDbType.VarCh ar)
'add parameters
cmdInsert.Param eters.Add(par1)
cmdInsert.Param eters.Add(par2)
da.InsertComman d = cmdInsert
This is not something very complicated that i am trying to do. All i am
doing is put data in a datagrid and using a
customised Insert query to insert a row. The data does appear on the
datagrid, but when i insert a new row and use da.update(ds,dt ) it gives
this error.
The same thing works fine if i use oledbQueryBuild er instead of my own
InsertCommand, but querybuilder does not usually fulfill the purpose always.
I created a very simplified AccessDatabase with just a table having two
columns.
Please see the code below and i would appreciate ur suggestions.
TIA
irfan
Dim con As New OleDbConnection (ConnString)
da = New OleDbDataAdapte r
ds = New DataSet()
Dim cmd As New OleDbCommand("S ELECT id,name from table1", con)
da.SelectComman d = cmd
da.Fill(ds, "mytable")
'create an insert command
Dim cmdInsert As New OleDbCommand( _
"INSERT INTO Table1( id, Name) VALUES (?,?)", con)
'create parameter
Dim par1 As New OleDbParameter( "id", OleDbType.LongV arWChar)
Dim par2 As New OleDbParameter( "Name", OleDbType.VarCh ar)
'add parameters
cmdInsert.Param eters.Add(par1)
cmdInsert.Param eters.Add(par2)
da.InsertComman d = cmdInsert
Comment