C# Data Insertion

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,
I am working on a Data Project, that involves records (rows) to be inserted from a Table in one database to an exactly similar table in another database. The table names and all field names and values are exactly same.
I am looking for Mass insertions or should i say, the easiest way to insert these records. What are my options? i don't want to use the individual OleDbCommand insert statements since that is a rather slow process.
Also the need to use DataAdapter and the schema details is not the best option since both the tables are exactly same.
However Database 1 is access and the Database 2 is SQL server. (So the connections are different and so on....)
Here is a little desc of the prob

Database1 (TableClientDetials) ----------- > (Insert all Records to) -------> Database2 (TableClientDetails)
From (Access) (On SQL Server)
 
Sunny,

I would actually use a parameterized OleDbCommand and cycle through the
rows, inserting the values from the old data source (retrieved through a
call to Fill on the data adapter) using the values in the data set. The
reason I would do this is because you can not change the RowState on the
data set to indicate that the records should be added. Because of that, you
will have to insert the records manually (or find a way to change the
RowState, possibly by copying the records to a new data set).

However, you could probably use DTS services through COM interop to copy
the records as well.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Sunny said:
Hi All,
I am working on a Data Project, that involves records (rows) to be
inserted from a Table in one database to an exactly similar table in another
database. The table names and all field names and values are exactly same.
I am looking for Mass insertions or should i say, the easiest way to
insert these records. What are my options? i don't want to use the
individual OleDbCommand insert statements since that is a rather slow
process.
Also the need to use DataAdapter and the schema details is not the best
option since both the tables are exactly same.
However Database 1 is access and the Database 2 is SQL server. (So the
connections are different and so on....)
Here is a little desc of the prob

Database1 (TableClientDetials) ----------- > (Insert all Records
to) -------> Database2 (TableClientDetails)
From (Access)
(On SQL Server)
 
Couldn't you just get a dataset from both tables and then add all of the rows from DataSet1 to DataSet2 and then call an update on DataSet2
I'm not usually the best person to ask as I am usually the one being helped rather then doing the helping but I think that would work o.k

jax
 
But that still needs an adapter with an insert statement that is the same thing as using a command with insert statement.
 
Back
Top