Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

connection string tricky problem, server is remote and I cannot access the version of it.

Posted on 2013-11-28
4
Medium Priority
?
574 Views
Last Modified: 2013-11-28
Hi;

My SqlConnection is causing an error "sqlConn.ServerVersion threw an exception of type System.InvalidOperationException".

<add key="MSSQLConnectionString" value="Server=aa.bb.cc.dd\server,1433;Database=Mydb;User ID=Foo;Password=Baz;Trusted_Connection=False"/>

Open in new window


And the code gives this error is as follows:

 con = new SqlConnection(ConfigurationSettings.AppSettings["MSSQLConnectionString"]);
                con.Open();

Open in new window


What to do?

Regards.
0
Comment
Question by:jazzIIIlove
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 26

Expert Comment

by:tigin44
ID: 39683259
error message?
0
 
LVL 12

Author Comment

by:jazzIIIlove
ID: 39683354
In the question..
0
 
LVL 12

Author Comment

by:jazzIIIlove
ID: 39683365
0
 
LVL 21

Accepted Solution

by:
Tapan Pattanaik earned 2000 total points
ID: 39683627
<connectionStrings>
    <add name="3Tier_ConnectionString" providerName="System.Data.SqlClient"
         connectionString="Server=TAPAN;Database=Employee;Uid=Sa;Pwd=tapan"></add>
   
  </connectionStrings>


 string conStr = System.Configuration.ConfigurationManager.ConnectionStrings["3Tier_ConnectionString"].ConnectionString;

SqlConnection con = new SqlConnection(conStr);
            con.Open();
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question