Hello
I am working in SQLSERVER 2008 and i want to fetch data from different server table please define how to fetch data from different server and also different database?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Davin MartynRank #285 · 8.8K reputationPosted Mar 22, 2015, 9:01 PM EDT
Khargesh RajputRank #616 · 3.9K reputationPosted Mar 17, 2015, 2:37 AM EDT
Davin MartynRank #285 · 8.8K reputationPosted Mar 20, 2015, 5:29 AM EDT
Khargesh RajputRank #616 · 3.9K reputationPosted Mar 20, 2015, 6:24 AM EDT
Now.in.web.config add two conectionstring
Named cnstr1 for.server1 and cnstr2. For server2.
Now on. Connection class or your page as you want; based on condition if you want database from server1 to use then. Add cnstr1 and execute query and if want to.usse server2 then add cnstr2 and write query to use server2
In detail
in web.config
and in connection class
var conn1 = ConfigurationManager.ConnectionStrings["cnstr1"].ConnectionString;
var conn2 = ConfigurationManager.ConnectionStrings["cnstr2"].ConnectionString;
now use these connectionstrings in your sqlconnection
Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted Mar 20, 2015, 5:47 PM EDT
SqlConnection con1 = new SqlConnection("Data Source=@Server_Name;initial catalog=@Database_Name; integrated security=true");
SqlConnection con2 = new SqlConnection("Data Source=@Server_Name;initial catalog=@Database_Name ; integrated security=true");