1

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>
6
  • What is the location of the outside server? Give us little more details. Commented Apr 24, 2015 at 20:55
  • 1
    Please paste your connection string and the error you get. Commented Apr 24, 2015 at 20:55
  • I have modified the question and I have included the connection config file Commented Apr 24, 2015 at 20:57
  • here is a link to C# connectionstrings that will show you how to configure your connection strings to many different databases.. also Google could have saved you a lot of time and trouble when asking a question please read the faq on how to ask a question on this site as well Commented Apr 24, 2015 at 20:58
  • You are using the same DNS and instance name of the server right? I.e. SERVER=MySqlNode\WebSql or SERVER=10.0.0.4\SQLEXPRESS et al. Also, as @MethodMan said, read up on the connection strings. Commented Apr 24, 2015 at 20:59

2 Answers 2

5

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").

Sign up to request clarification or add additional context in comments.

Comments

0

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.