Home All Groups Group Topic Archive Search About

quickly transferring data from a DbDataAdapter to TableAdapter?

Author
4 Oct 2006 7:17 PM
chirag
Basically, I have the following code which fills up a DbDataAdapter
(which is of DataAdatper  type). Is there a quick way to map the
columns and transfer the data in this adapter to a new TableAdapter ?
This new TableAdapter will be linked to a SQL database.
Thanks!
Chirag

DbProviderFactory factory =
DbProviderFactories.GetFactory("System.Data.OleDb");

DbDataAdapter dbDataAdapter = factory.CreateDataAdapter();

DbCommand selectCommand = factory.CreateCommand();
selectCommand.CommandText = excelCommand;

DbConnection connection = factory.CreateConnection();
connection.ConnectionString = excelConnectionString;

selectCommand.Connection = connection;

dbDataAdapter.SelectCommand = selectCommand;

DataSet aEESamples = new DataSet();

dbDataAdapter.Fill(aEESamples);

Author
5 Oct 2006 1:01 AM
LouArnold
Just to clarify some concepts
The DataAdapter is not filled with data, It is the Dataset that is filled
via the DataAdapter. The DataAdpater is provided by the database makers, and
the Dataset is part of the .NET framework.

Beyond that its not clear what you are trying to do. Are you taking data
from an Excel spreadsheet and trying to put it into the SQL database? If so,
I don't think you can just fill the Dataset and then "empty" it into the
database. :)   Nice try, though!
Author
5 Oct 2006 1:15 AM
LouArnold
The Dataset contains a collection of tables and columns. After filling the
dataset, it might be possible to copy tables to a second dataset for the SQL
database. The question is: when is this done, before or after the 2nd
connection has been opened? Before or after the dataset is filled? This is
the problem to solve.

AddThis Social Bookmark Button