Click here to Skip to main content
15,885,839 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a source database in one system. I want to create a target Database (with same schema as Source database) in another system in a different network (both systems are not connected in any way).
now we are creating a dump on system 1 and using a stick to copy it into system 2. But we are looking for a better solution through C#.

I have already created sqldump on system 1 and now I need help on how I can access the system 2 from system 1 to use the dump file and create a target database or should I be writing a code to be run in system 2 that in turn takes the dump of system1 database? how should I be going about with this?

I will go on further to do some database verification once the Target db is created, comparing the 2 databases and syncing the data among the two.
So I am looking for a C# solution.

any ideas?

P.S. code that creates sqldump on system 1:

C#
                string constring1 = "SERVER=localhost;" + "DATABASE=;" + "UID=root;" + "PASSWORD=;" + "Convert Zero Datetime=True;" +
"Allow Zero Datetime=True";
                
                using (MySqlConnection conn = new MySqlConnection(constring1))
                {
                    using (MySqlCommand cmd = new MySqlCommand())
                    {
                        using (MySqlBackup mb = new MySqlBackup(cmd))
                        {
                            cmd.Connection = conn;
                            conn.Open();
                            mb.ExportInfo.AddCreateDatabase = true;
                            mb.ExportInfo.ExportTableStructure = true;
                            mb.ExportInfo.ExportRows = false;
                            mb.ExportToFile(file1);
                        }
                    }
                }
Posted
Comments
Maciej Los 24-Apr-15 2:06am    
So... If system1 and system2 are not connected, how do you want to copy data between them?
RevathySanthanam 24-Apr-15 6:03am    
right now, it is copied by taking a sqldump from system1 through usb disk n copied into system2. is it possible to do it any other better way?

1 solution

Option 1: By using web services.

Create a web server and host a web service at server 2.
Server 1 will send over the byte[] (byte array) to server 2 through the web service.

Option 2: By using a web page

At server 2, create a ASP.NET web page that accept a http post.
Server 1 will access the web page programmatically and upload the file.
Server 2, once the file received at the web page, ASP.NET engine will process it.

Option 3: By opening a TCP Client/Server port using C# at server 2

Create a C# Socket at server 2.
Server 1 will connect the socket then transmit the byte[] to server 2 through the socket.
 
Share this answer
 
v3
Comments
RevathySanthanam 24-Apr-15 10:26am    
Option 2 might be a good choice for us because we have many products and many systems for each product.
Thank you for all the enlightening options.
Maciej Los 24-Apr-15 15:17pm    
5ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900