uriDium
uriDium

Reputation: 13420

Can I use DataTables to import data from one database into another?

I need to create a quick and dirty solution to migrate data from database into another. This is only being used a proof of concept. Long term we will use .NET's Sync Framework.

The databases are identical. The solution is going to be used as an OCA (occasionally connected application).

I am not sure if the above is possible. I had most of it working and I was cloning the source DataTable. I then had the problem where the cloned DataTable wasn't pointing anywhere.

Upvotes: 0

Views: 968

Answers (3)

Rob Fonseca-Ensor
Rob Fonseca-Ensor

Reputation: 15621

What you're proposing should work. But you might find it easier (and you'll definitely see better performance) with the SqlBulkCopy class.

(This is a code-focused solution)

Upvotes: 3

Santiago Cepas
Santiago Cepas

Reputation: 4094

You can use the Sql Server Import and Export Wizard (dtswizard.exe). It creates an Integration Services package that you can then save and execute whenever you want.

Upvotes: 1

Rubens Farias
Rubens Farias

Reputation: 57936

Short answer: You can load your DataTable and save it into another database by using a different DataAdapter.

But, for a code less approach, you can to use SQL Server Database Publishing Toolkit as stated here.

Upvotes: 1

Related Questions