quickly transferring data from a DbDataAdapter to TableAdapter?

C

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);
 
G

Guest

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!
 
G

Guest

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.
 

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