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 oledbQueryBuilder 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 OleDbDataAdapter
ds = New DataSet()
Dim cmd As New OleDbCommand("SELECT id,name from table1", con)
da.SelectCommand = 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.LongVarWChar)
Dim par2 As New OleDbParameter("Name", OleDbType.VarChar)
'add parameters
cmdInsert.Parameters.Add(par1)
cmdInsert.Parameters.Add(par2)
da.InsertCommand = cmdInsert