Read from one, write into another data source



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.

.



Relevant Pages

  • Re: DriverManager vs. DataSource?
    ... > class to establish the connection. ... it is possible to use the DriverManager interface. ... JDBC driver jars go in a 'common' directory in the container. ... > the DataSource interface will typically be registered with a JNDI ...
    (comp.lang.java.databases)
  • Re: Connection for Data Source in SSAS 2005 Tutorial Lesson 6
    ... double click on the datasource and then click on ... I noticed that my server explorer showed a connection to ... When connecting to SQL Server 2005, this failure may be caused by the ... not be made to the data source with the DataSourceID of 'Adventure ...
    (microsoft.public.sqlserver.olap)
  • Re: ConnectionPoolDataSource + MM MySQL + Tomcat4
    ... to work with Tomcat 5.0.28 and MySQL or Oracle. ... <ResourceParams> ... in functions needing DB access, use the DataSource variable ... to create a Connection ...
    (comp.lang.java.programmer)
  • Re: Read from one, write into another data source
    ... this sounds like you're using ADO to to transport (bulk copy) data. ... > contents into another DataSource. ... > OleDbConnection connection = adapter.SelectCommand.Connection; ...
    (microsoft.public.data.ado)
  • Re: Datagrid help, please
    ... Drop a grid on the form and specify it's datasource ... connection string in advance you can set it in the ... > I am working to converta Delphi application to a C# Winform application. ...
    (microsoft.public.dotnet.languages.csharp)