Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vb.NET 2015 desktop need help getting app.confile file's SQL Server connectioin string 1

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
0
36
US
The Connection string is correct since I used it as a variable prior.
Error is "ConfigurationManager is not declared. it may be inaccessible due to its protection level."

here is how I'm trying to call it

Code:
      Imports System.Configuration
Dim ConnectionString As String = ConfigurationManager.ConnectionStrings("HistDataLocaldbConnectionString").ConnectionString
   ...
here is my app.config file, which I'm not sure is correct.
Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
     <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
    </startup>
    <connectionStrings>
      <add name="HistDataLocaldbConnectionString"
       providerName="System.Data.ProviderName"
       connectionString="Server=MyServer\SQLExpress;Database=MyDb;Integrated Security=true;" />
    </connectionStrings>
</configuration>






DougP
 

Do you have a reference to System.Configuration in your app? Got to Project -> Add Reference, and in there select System.Configuration.

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
So just merely having Imports System.Configuration without adding it to the references will not work.
I've been out of VB.NET for a while...
OK I get it now
Thanks this solved my problem

Have a star

DougP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top