doramail05
asked on
Connection String in app.config for console app vb.net
While trying to connect to SQL with connectionstring in console app with app.config, saying that 'My.Settings.theDB' is not a member of Test.My.MySettings.
app.config<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="theDB" connectionString="\.SQLExp ress"
providerName="System.Data. SqlClient" />
</connectionStrings>
</configuration>
console app
Dim oConn As New SqlConnection(My.Settings. theDB)
app.config<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="theDB" connectionString="\.SQLExp
providerName="System.Data.
</connectionStrings>
</configuration>
console app
Dim oConn As New SqlConnection(My.Settings.
Instead of My.Settings.theDB, try System.Configuration.Confi gurationMa nager.Conn ectionStri ngs("theDB ").Connect ionString
You will have to add a reference to System.Configuration and then you can use an Imports statement to shorten that down a little...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
To access an entry in the configuration file through My.Settings, you need to first define it manually in the Settings tab of the project's properties window, available at the bottom of the Project menu.