Reputation: 281
I have a console application and in the App.config I need to add a connectionString to another SQL server that is in the same network.
If I try the connectionString to a local server by only passing the Server='localhost' its worked but I cannot make it work for an outside server.
Thanks
Here is the connection file
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup>
<connectionStrings>
<add connectionString="Server=LocalServer;database=DAtaBase;user=UserName;pwd=Password" name="Connection"/>
</connectionStrings>
</configuration>
Upvotes: 1
Views: 21000
Reputation: 18863
inside of a app.config / web.Config file you would have the following and this is a simple and easy way to connect to a sql server database.. also confirm what database you are using because the connection string can be different depending on the DBMS
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="DbConn" connectionString="Data Source=the name of your database;User Id=UserName;Password=Password;"/>
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
</configuration>
Upvotes: 0
Reputation: 3082
Example connection to outer server:
<connectionStrings>
<add name="Namespace.Settings.outerSQL" connectionString="Data Source=192.168.0.100\SQLEXPRESS;Initial Catalog=database_name;User ID=user;Password=password"/>
</connectionStrings>
You need address to remote server and credentials provided (if it's not Windows auth, for which you use "Integrated Security").
Upvotes: 5