Place connectionString in web.config. Why is not working?

  • Thread starter Thread starter Shapper
  • Start date Start date
S

Shapper

Hello,

I have this connectionString in a DataReader:
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;
Ole DB Services=-4; Data Source=C:\db.mdb"

It's working fine. Now i replaced this line with this one:
Dim connectionString As String =
System.Configuration.ConfigurationSettings.AppSettings("connectionString")

And I added this in my web.config file:
<appSettings>
<add key="connectionString"
value="Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data
Source=C:\db.mdb" />
</appSettings>

I got this error:
System.InvalidOperationException: The ConnectionString property has
not been initialized.

Why? Am I doing something wrong?

Thank You,
Miguel
 
The code looks correct. Are you sure you don't have another variable called
ConnectionString that is not set up right?

Brendon
 
Back
Top