0

I have two computers in local network i want to insert from one table From PC(A) to other table PC(B)here is an example:

SqlConnection con = new SqlConnection(@"Data Source=(local);Initial Catalog=Db;User ID=sa;password=xxxxx");
SqlConnection conn = new SqlConnection(@"Data Source=(local);Initial Catalog=Db;User ID=sa;password=xxxxx");

SqlCommand cmd8 = new SqlCommand("insert into [192.168.1.11].Db.dbo.MArket select * from MARKET", conn);//second market is been exist in my local database,too
                cmd8.ExecuteNonQuery();
  • why don't you have the tables residing in a centralized database.. also this approach has a lot of other settings in the setup of the database that you have to take into account for example setting up to make sure both databases can be connected to TCP/IP & NamedPipes you have to allow for remote access to the other Database which you would probably want to be on a Shared Drive on the local.. is this for a company or for yourself..? I personally think that your current approach is not the way to go.. this is not the same as working with MS Access for example – MethodMan Sep 28 '16 at 16:15
  • 2
    try creating Linked database server http://stackoverflow.com/a/189431/96505 and then copy the contents from Linked Db tp your target table , it is far easy. try it. – Vishwa Ratna Sep 28 '16 at 16:20
  • The meaning of Database - a structured set of data held "IN A COMPUTER", especially one that is accessible in various ways. I am not sure why your two tables are in different machines in different databases. Can you please provide more clarity? – Justin Samuel Sep 28 '16 at 18:08

0 Answers0