|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
quickly transferring data from a DbDataAdapter to TableAdapter?(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); 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! 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. |
|||||||||||||||||||||||