0

Trying to connect in a remote database via IP using WPF, I place the following code in the App.config file.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
    </startup>
  <connectionStrings>
    <add connectionString="Data Source=tcp:XXX.XXX.X.XX,1433; User Id=ex****;Password=ex*******; Initial Catalog=database_name;" name="ConString"/>
  </connectionStrings>  
</configuration> 

The above throws me a message that says "An unhandled exception of type 'System.TypeInitializationException' occurred in PresentationFramework.dll"

I placed "tcp" because is what I met googling for connecting to a remotely database over IP(my case). Do I have other "options" instead of that?

Notice that I am connecting over vpn and also that I have full access using SQL Management Studio.

Expanding the error message gives me the bellow description: Error message

As I said I have full access in the remotely database via SQL Management Studio, so I suppose that the problem has to do with the syntax of the connectionstring code in App.config file.

Except all, in the Catalog I am placing the name of the database right?

17
  • Do you have <configSections> <!-- connectionstrings go in here --> </configSections> Commented May 19, 2016 at 7:36
  • @Master117 Can you explain that please? The above is my full code in the App.config file. Commented May 19, 2016 at 7:38
  • Could you show related code? And we need to know which line is problem. By the way, will this WPF be deployed to users' computers? Be careful with your password. You're delivering the password on paper together. Commented May 19, 2016 at 7:45
  • @KayLee This is my full code, I created a blank WPF app and I am trying from the beginning to be connected in a remotely database. All I have is an IP, a username and a password. After placing the code above, I tried to run the project, in order to see if everything is ok and then got the message "An unhandled exception of type 'System.TypeInitializationException' occurred in PresentationFramework.dll" I totally confused on how to be connected. Commented May 19, 2016 at 7:48
  • Does its show the line with the error? Commented May 19, 2016 at 7:49

2 Answers 2

2

XML is case-sensitive. The S in string must be capital:

<connectionStrings>
    <add connectionString="Data Source=tcp:XXX.XXX.X.XX,1433; User Id=ex****;Password=ex*******; Initial Catalog=database_name;" name="ConString"/>
</connectionStrings> 
Sign up to request clarification or add additional context in comments.

Comments

0

You can try forcing the usage of TCP/IP instead of named pipes for your connection with: Network Library=DBMSSOCN; after the Data Source element.

2 Comments

Just tried your suggestion but nothing. I placed "tcp" because is what I met googling for connecting to a remotely database over IP. Do I have other options instead of that?
You can find the list of avalable protocols here. But if that didn't help I doubt that other options of that parameter will work for you.

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.