williecg
asked on
sql insert records from one database to another database
Hello Experts,
I have 2 databases, each with 1 table.
Database_old , table_old
Database_new, table_new
Each table has name, address, email
In ASP NET, I want to be able to insert all of the records from database_new/table_new into database_old/table_old
Here is the connection string I use for Database_old
H_connString = "Provider=Microsoft.ACE.OL EDB.12.0;D ata Source=" & Server.MapPath("") & "\app_data\ Database_old.accdb;"
Do I need to open a connection string for Database_new?
What is the sql to insert all records in Database_new/table_new into Database_old/table_old ?
Thanks,
WCGee
I have 2 databases, each with 1 table.
Database_old , table_old
Database_new, table_new
Each table has name, address, email
In ASP NET, I want to be able to insert all of the records from database_new/table_new into database_old/table_old
Here is the connection string I use for Database_old
H_connString = "Provider=Microsoft.ACE.OL
Do I need to open a connection string for Database_new?
What is the sql to insert all records in Database_new/table_new into Database_old/table_old ?
Thanks,
WCGee
ASKER
Thanks for your response.
I am a newbee and what I understand is limited.
I conceptually understand your logic, but I get tripped up on the specifics of the commands.
I am using asp net vb.
Could you please provide a code example to do what you described?
Thanks,
WCGee
I am a newbee and what I understand is limited.
I conceptually understand your logic, but I get tripped up on the specifics of the commands.
I am using asp net vb.
Could you please provide a code example to do what you described?
Thanks,
WCGee
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
been on holiday. Thanks for the information, getting me in the right direction.
Basically you need to do it in a few steps.
Open the connection string to the old DB . . . do a select * from old_table.
Execute the command as a datareader.
Build the DataReader (dr) with the following code:
Open in new window
Then open a connection the new database
Execute a command using stringBuilder.ToString() as NonExecuteQuery
Close your connections and cleanup.