Data transfer..... (walkthroughs ?)

Last post 04-26-2007 11:47 AM by paulizaz. 2 replies.

Sort Posts:

  • Data transfer..... (walkthroughs ?)

    04-11-2007, 6:24 AM
    • Member
      point Member
    • paulizaz
    • Member since 04-11-2007, 6:18 AM
    • Posts 2

    Hello,

    I am asked to write a C# class that maps data from an old database to another database on a new server.

     
    Is there a walkthrough to help me?, does anyone know of any other resources?

     

    Any help appreciated..........
  • Re: Data transfer..... (walkthroughs ?)

    04-12-2007, 10:29 PM
    Answer

    Hi paulizaz,

     

    SQL Server provides the import/export tool to let us copy and transfer data easily. I recommend you to use it.

     

    We can write our own class to do that, but I think it cannot as efficient and powerful as the tool SQL Server provided.

     

    In my opinion, firstly we shall get the table schema from the table in old database and create the same or similar table in new database. Secondly we read the data from old table to a in memory DataTable object. At last, insert all the rows from DataTable to the table in new database.

     

    Here are some links helpful for this scenario:

    http://support.microsoft.com/kb/310107

    http://msdn2.microsoft.com/en-us/library/fksx3b4f(VS.80).aspx

     

    About how to insert all the data from DataTable to database table, here is a sample:

            foreach (TableRow row in table.Rows)

            {

                command.CommandText = String.Format("INSERT INTO table VALUES ( {0},{1})", row[0], row[1]);

                connection.Open();

                command.ExecuteNonQuery();

                connection.Close();

            }

     

     

    Sincerely,
    Benson Yu
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.
  • Re: Data transfer..... (walkthroughs ?)

    04-26-2007, 11:47 AM
    • Member
      point Member
    • paulizaz
    • Member since 04-11-2007, 6:18 AM
    • Posts 2

    Thanks,

     

    But is this suitable for a complete site migration?

    From one SQL database to another where the fields may differ slightly.

     

    Regards,
     

Page 1 of 1 (3 items)