Newbie Question - Updating OLE Tables

  • Thread starter Thread starter Jerry
  • Start date Start date
J

Jerry

This should be soooo simple but I just can't figure it out. All I
want to do is open an Excel spreadsheet, update it and write back out
again! For some reason though I can't get the update command to work.
I've tried using commandbuilder, that failed because the update
command doesn't return key column information.
Here's what I've got so far.
Dim DS As New System.Data.DataSet
Dim DA As System.Data.OleDb.OleDbDataAdapter
Dim DC As System.Data.OleDb.OleDbConnection

DC = New System.Data.OleDb.OleDbConnection( _
"provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source=" & ExcelSpreadsheet.FileName & "; Extended
Properties=Excel 8.0;")

' Select the data from POINTS sheet of the workbook.

DA = New System.Data.OleDb.OleDbDataAdapter("select * from
[Points$]", DC)

Dim CB As OleDb.OleDbCommandBuilder = New
OleDb.OleDbCommandBuilder(DA)

DA.Fill(DS,"Reference")
DataGrid2.DataSource = DS

All this seems to work, at least I don't get any errors :-), but how
do I write the changes back again?

TIA

Doug
 
You use the Update method on the DataAdapter, DA in your case.
Yes, I've tried that but it didn't work. I used Commandbuilder to
create the UPDATE, INSERT & DELETE commands but that failed because
"the update command doesn't return key column information".
How do you set the key column info on an OLEDB?

Regards
Doug
 
Back
Top