J
John Dann
I've moved some code for updating an Access database from an old
project (no longer to hand unfortunately) to a new one and keep
getting an 'Update requires a valid InsertCommand when passed DataRow
collection with new rows'.
The Access database is a newly created one with no preexisting
datarows. (I can see this OK from within Access and the Table name,
column names etc are all OK.)
Code outline is as follows:
--------------------------------
dim ds as new dataset
Function MyFunction
ds.Clear() 'MyFunction may be called iteratively
Dim WLDBConn As New OleDbConnection(WLDBConnString)
Dim da As New OleDbDataAdapter(WLDBGenOpen, WLDBConn)
da.FillSchema(ds, SchemaType.Source)
[ Populate ds]
For i = 1 to whatever
Dim dr As DataRow = ds.Tables(0).NewRow
'Assign column values here
ds.Tables(0).Rows.Add(dr)
Next i
da.Update(ds)
End Function
-----------------------------
The error's generated at the da.update line.
The WLDBGenOpen and WLDBConnString strings work in other functions of
the project without problem so I don't think they're at fault. After
the 'Populate ds' process, I can bind the resulting ds to a grid and
all looks fine. So there's something in the Update syntax or whatever
that's faulty.
Any thoughts please?
JGD
project (no longer to hand unfortunately) to a new one and keep
getting an 'Update requires a valid InsertCommand when passed DataRow
collection with new rows'.
The Access database is a newly created one with no preexisting
datarows. (I can see this OK from within Access and the Table name,
column names etc are all OK.)
Code outline is as follows:
--------------------------------
dim ds as new dataset
Function MyFunction
ds.Clear() 'MyFunction may be called iteratively
Dim WLDBConn As New OleDbConnection(WLDBConnString)
Dim da As New OleDbDataAdapter(WLDBGenOpen, WLDBConn)
da.FillSchema(ds, SchemaType.Source)
[ Populate ds]
For i = 1 to whatever
Dim dr As DataRow = ds.Tables(0).NewRow
'Assign column values here
ds.Tables(0).Rows.Add(dr)
Next i
da.Update(ds)
End Function
-----------------------------
The error's generated at the da.update line.
The WLDBGenOpen and WLDBConnString strings work in other functions of
the project without problem so I don't think they're at fault. After
the 'Populate ds' process, I can bind the resulting ds to a grid and
all looks fine. So there's something in the Update syntax or whatever
that's faulty.
Any thoughts please?
JGD