Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

How do I reference a connection string in Web.Config?

  Asked By: Bryant    Date: Jan 25    Category: Asp.net    Views: 3319
  

Here is the setting in Web.Config:


<system.web>
<appSettings>
<add key="ConnectionString"
value="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Inetpub\wwwroot\di\dancedance.mdb;Persist
Security Info=False"/>
</appSettings>

Here is what worked when the string was a function in
a data.vb file:

Dim myConnection As New
OleDbConnection(fConnectionString)

I would like to use the Web.Config string but I can't
seem to reference it when I'm initializing
"myConnection".

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Nagaraju Iyaner     Answered On: Jan 25

Imports System.Configuration.ConfigurationSettings

....

Dim myConnection As New OleDbConnection(.AppSettings("fConnectionString"))

 
Didn't find what you were looking for? Find more on How do I reference a connection string in Web.Config? Or get search suggestion and latest updates.




Tagged: