saving changed data from dataset to datasource

@

@piranha

hello,
when i'm trying to save changed data from the dataset to datasource(an excel
file)
i get this error
An unhandled exception of type 'System.InvalidOperationException' occurred
in system.data.dll
Additional information: Update requires a valid UpdateCommand when passed
DataRow collection with modified rows.

i use this code (straight from msdn)
Dim DS As System.Data.DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
Dim MyConnection As System.Data.OleDb.OleDbConnection

MyConnection = New System.Data.OleDb.OleDbConnection( _
"provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source=C:\myData.XLS; " & _
"Extended Properties=Excel 8.0;")
' Select the data from Sheet1 of the workbook.
MyCommand = New System.Data.OleDb.OleDbDataAdapter( _
"select * from [Sheet1$]", MyConnection)

DS = New System.Data.DataSet()
MyCommand.Fill(DS)

'Here code to change something in dataset

'this i use to update
mycommand.update(ds)

MyConnection.Close()

anybody?
thanx in advance
 
B

Bernie Yaeger

Hi,

You need either a commandbuilder or manually created updatecommands in order
to transfer changes to the back end.

HTH,

Bernie Yaeger
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top