Link to home
Start Free TrialLog in
Avatar of sherbug1015
sherbug1015Flag for United States of America

asked on

Using a DSN in App.config under <appsettings>

In the App.config file under <appsettings> how do I bind a DSN name to the value property.  

I have tried this

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

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.
Avatar of chapmanjw
Flag of United States of America image

Can you show the code you are using to access the data with this application setting (your c# or vb code)?
Avatar of sherbug1015


Dim strConnection As String = ConfigurationSettings.AppSettings("IQSConn")
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):
<add name="IQSConn" connectionString="DSN=dsnname;integrated security=true"
I am getting an error that <connectionStrings> is not a child element of <appsettings>

Avatar of lenordiste
Flag of France image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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 = ????????

Expert would not complete the question.