How to connect 2 mysql tables with 2 connection string

Posted by denonth on Stack Overflow See other posts from Stack Overflow or by denonth
Published on 2012-06-01T16:36:55Z Indexed on 2012/06/01 16:40 UTC
Read the original article Hit count: 229

Filed under:
|
|
|

Hi all I need to connect 2 tables from 2 mysql databases that have 2 different connection strings and each is on the different server.

I have this query:

cmd = new MySqlCommand(String.Format("INSERT INTO {0} (a,b,c,d) SELECT (a,b,c,d) FROM {1}", ConfigSettings.ReadSetting("main_table"), ConfigSettings.ReadSetting("main_table")), con);

So both table have the same columns. Thats why I have only one ConfigSettings.ReadSetting("main_table") for both of them as they are same.

I have 2 connection strings and each is pointing to their server:

 con.ConnectionString = ConfigurationManager.ConnectionStrings["con1"].ConnectionString;
 con2.ConnectionString = ConfigurationManager.ConnectionStrings["con2"].ConnectionString;

How to make this cmd to be workking with 2 different connection strings and with the same name for the table. Table name will change that's why it is saved in config.

© Stack Overflow or respective owner

Related posts about c#

Related posts about mysql