Solved

Using a DSN in App.config under <appsettings>

Posted on 2010-09-13
7
877 Views
Last Modified: 2012-05-10
In the App.config file under <appsettings> how do I bind a DSN name to the value property.  

I have tried this

<appsettings>
<add key="keyname" value="DSN=dsnname;integrated security=true">
</appsettings>

I am getting an error "keyword dsn not supported".  I must use the DSN name as the server names may not be the same but the DSN will point to the correct server when the application is moved to the production environment.

I am using the .Net 4.0 Framework.
0
Comment
Question by:sherbug1015
  • 4
  • 2
7 Comments
 
LVL 21

Expert Comment

by:chapmanjw
ID: 33667004
Can you show the code you are using to access the data with this application setting (your c# or vb code)?
0
 

Author Comment

by:sherbug1015
ID: 33667498
Dim strConnection As String = ConfigurationSettings.AppSettings("IQSConn")
0
 
LVL 11

Expert Comment

by:lenordiste
ID: 33667544
the error you are getting is most probably coming from your database connection string: you need to add a provider name else the DNS keyword is detected has being invalid.

I think the best way to tackle this is to use the connectionStrings node like below (assuming you are using odbc):
<appSettings>
<connectionStrings>
<add name="IQSConn" connectionString="DSN=dsnname;integrated security=true"
providerName="System.Data.Odbc"/>
</connectionStrings>
</appSettings>
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:sherbug1015
ID: 33667574
I am getting an error that <connectionStrings> is not a child element of <appsettings>

0
 
LVL 11

Accepted Solution

by:
lenordiste earned 500 total points
ID: 33667630
oups my bad; I typed too fast ! Here is the right structure:

<configuration>
  <appSettings>
   ....
  </appSettings>
   <connectionStrings>
       <add name="IQSConn" connectionString="DSN=dsnname;integrated security=true"
             providerName="System.Data.Odbc"/>
   </connectionStrings>
0
 

Author Comment

by:sherbug1015
ID: 33667672
OK  since I am no longer using Appsettings, like this
Dim strConnection As String = ConfigurationSettings.AppSettings("IQSConn")

How to I use the values between the <connectionString> tags

Dim strConnection as String = ????????


0
 

Author Closing Comment

by:sherbug1015
ID: 33677103
Expert would not complete the question.  
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now