how export each table into separate file (DUMP)

how export each table into separate file (DUMP)

Postby paul_huynh » Fri 16 Dec 2011 19:15

Please help. I recently downloaded a trial 30 days dotConnect for MySQL. I plan to buy it after trial expired. I am writing an web application (C#) to allow user backup and restore MySQL database. I don't know how to export each table into separate file while dumping it.
Please help. Thanks
Posts: 4
Joined: Fri 16 Dec 2011 19:04

Postby Pinturiccio » Tue 20 Dec 2011 07:50

I have created a little example that allows backing up each table to a different file. The sample backs up all the tables in the 'test' database.
Code: Select all
       MySqlConnection conn = new MySqlConnection("Your connection string; database=test;");
            MySqlCommand comm = new MySqlCommand("show tables", conn);
            DataTable dt = new DataTable();
            MySqlDataAdapter da = new MySqlDataAdapter(comm);

            MySqlDump dump = new MySqlDump();
            dump.Connection = conn;
            dump.Database = "test";

            string[] fileNames = new string[dt.Rows.Count];
            for (int i = 0; i < dt.Rows.Count; i++)
                fileNames[i] = "D:\tempdir\file" + i.ToString()+".txt";
                dump.Tables = dt.Rows[i][0].ToString();

In my case, I have received 71 files in folder 'D:\tempdir'
Devart Team
Posts: 2084
Joined: Wed 02 Nov 2011 09:44

Return to dotConnect for MySQL