Read from one, write into another data source
- From: "Maxime LABELLE" <MaximeLABELLE@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 29 May 2005 01:37:01 -0700
Hi,
I'm trying to read data from a datasource in a DataSet, and write the
contents into another DataSource.
I have succeeded in using an OleDbDataAdapter to select, update, insert and
delete records from one datasource automatically (via its SelectCommand,
UpdateCommand, InsertCommand and DeleteCommand properties).
However, I would like the insert, update and delete done against a different
datasource than that of the select. The problem I face is that I don't know
how to instruct the dataset to alter the RowState of its rows based on the
contents of the destination datasource.
I have tried something like this:
adapter.InsertCommand.Connection = another_connection;
// save current connection
OleDbConnection connection = adapter.SelectCommand.Connection;
// change connection
adapter.SelectCommand.Connection = another_connection;
// fill from alternate data source (refresh the row states ?)
adapter.Fill(dataset_);
// restore original connection
adapter.SelectCommand.Connection = connection;
But that fails to refresh the row states. I would expect that each row in
the dataset that do not correspond to one row in the alternate datasource to
be modified to "INSERTED", but that does not appear to be the case.
Is there a simpler way to achieve this? Do I need to create another,
similar, DataSet in which I manually add rows from the initial DataSet?
Thanks for your time.
.
- Follow-Ups:
- Re: Read from one, write into another data source
- From: news.microsoft.com
- Re: Read from one, write into another data source
- Prev by Date: Re: Connection object question
- Next by Date: Re: Connection object question
- Previous by thread: SQLSummit.com catalog of drivers and data providers (ODBC, OLE DB, .NET, etc.)
- Next by thread: Re: Read from one, write into another data source
- Index(es):
Relevant Pages
|
|