Solved

Using a DSN in App.config under <appsettings>

Posted on 2010-09-13
7
880 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

932 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

13 Experts available now in Live!

Get 1:1 Help Now