locked
How to Import and Export data from one database to another database using C# RRS feed

  • Question

  • Can you give me the suggestions how import and export of data from one database to another database  can be done using C#. I don't want use ssis package.

    Monday, February 27, 2012 6:53 AM

Answers

  • I meant is it just 1 table or a set of relational tables. If relational, you have to transfer them keeping the relations in place.

    You can do this in two ways

    • Transfer all the parent table rows, then it's childs and then down the hierarchy.
    • Transfer one by one reord with all its sub data.

    Do you want to transfer them all at once and done (or) transfer them in timely intervals i.e synchronizing the databases on the fly.

    In this case, you have to work out a method to keep track of which records have been synchronized and which needs to.

    This might need adding an additional column or adding an additional table which keeps record of the synchronized records.

    or you could keep a variable in app like last sync time and sync records after that time. In this case you need to persist the values somewhere when the process shuts down so that it can find it later. Your existing table too should have a date created column.

    So quite a few ways.

    Are both the databases SQL Server?? You could consider Mirroring/Replication too for the task.

    Hope this helps.


    Welcome to MSDN Forums.
    Feel free to ask your questions and Please Note to Vote all helpful topics and Mark all answering posts.

    You Value Community's efforts and Community values your faith.
    - Arun Kumar Allu

    Monday, February 27, 2012 7:59 AM

All replies

  • I don't want use ssis package.


    Is this a personal preference or licensing/other issue related. These tools are created to fulfill this purpose. Why not use them.

    However, to transfer data betwwen two databases, you have to build a custom app keeping attention the Relations in the database.

    Check this thread @ http://stackoverflow.com/questions/3158297/data-import-export-of-large-data-sets-with-net

    Can you provide your requirements in detail so that we can help you.


    Welcome to MSDN Forums.
    Feel free to ask your questions and Please Note to Vote all helpful topics and Mark all answering posts.

    You Value Community's efforts and Community values your faith.
    - Arun Kumar Allu

    Monday, February 27, 2012 7:13 AM
  • I have two  databases in different servers which has similar tables,I want to import data from one database table and export to other database table  I want do it only using C#. 

    Monday, February 27, 2012 7:23 AM
  • I meant is it just 1 table or a set of relational tables. If relational, you have to transfer them keeping the relations in place.

    You can do this in two ways

    • Transfer all the parent table rows, then it's childs and then down the hierarchy.
    • Transfer one by one reord with all its sub data.

    Do you want to transfer them all at once and done (or) transfer them in timely intervals i.e synchronizing the databases on the fly.

    In this case, you have to work out a method to keep track of which records have been synchronized and which needs to.

    This might need adding an additional column or adding an additional table which keeps record of the synchronized records.

    or you could keep a variable in app like last sync time and sync records after that time. In this case you need to persist the values somewhere when the process shuts down so that it can find it later. Your existing table too should have a date created column.

    So quite a few ways.

    Are both the databases SQL Server?? You could consider Mirroring/Replication too for the task.

    Hope this helps.


    Welcome to MSDN Forums.
    Feel free to ask your questions and Please Note to Vote all helpful topics and Mark all answering posts.

    You Value Community's efforts and Community values your faith.
    - Arun Kumar Allu

    Monday, February 27, 2012 7:59 AM