How to Connect to a Database on Another Computer With SQL Server
The SQL Server is connecting through Windows authentication, how to write the connection string in web.config file??
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
Pravin MoreRank #1,419 · 1.2K reputationPosted Nov 15, 2011, 11:07 PM EST
Set in your connection string IP address of remote server. E.g.
"Data source=112.160.0.18; Database=dbname;User ID=urusername;password=****"
where 192.168.0.13 is your remote server IP and MyDb is your database name.
Also, make sure to configure your SQL Server Express to allow remote connections! Those are disabled by default after installation.
Thanks,
Pravin.
Prabhu RajaRank #861 · 2.6K reputationPosted Nov 15, 2011, 11:05 PM EST
http://www.c-sharpcorner.com/uploadfile/mamta_m/storing-and-retrieving-connection-strings-in-Asp-Net-2-03-5/
Different type of Connection Strings:
http://www.connectionstrings.com/sql-server-2005
Datta KharadRank #2,135 · 668 reputationPosted Nov 15, 2011, 11:17 PM EST
string connectionstring ="data source=[Servername];initial catalog=Northwind; integrated security=SSPI;persist security info=False; Trusted_Connection=Yes."
Where datasource will be computer name or IP Address, and initial catalog is the name of database.
For Windows Aunthetication you can use either MyDbConn1 or MyDbConn2:-
In web.config file...
connectionString="Server=MyServer;Database=MyDb;Trusted_Connection=Yes;"/>
connectionString="Initial Catalog=MyDb;Data Source=MyServer;Integrated Security=SSPI;"/>
// Retrieving connection string from Web.config.
String connString = WebConfigurationManager.ConnectionStrings["MyDbConn1"].ToString();
SqlConnection conn = new SqlConnection(connString);
conn.Open();
Please mark as Accepted answer if your query resolved.