By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,259 Members | 1,349 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,259 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.AppSett ings("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

Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
The code looks correct. Are you sure you don't have another variable called
ConnectionString that is not set up right?

Brendon

"Shapper" wrote:
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.AppSett ings("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

Nov 19 '05 #2

P: n/a
The code looks correct. Are you sure you don't have another variable called
ConnectionString that is not set up right?

Brendon

"Shapper" wrote:
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.AppSett ings("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

Nov 19 '05 #3

P: n/a
Make sure the <appSettings> is placed outside of the <system.web> element.
I think it must go under the configuration element like it shows here:
http://www.dotnetjunkies.com/quickst...gretrieve.aspx
--
TDAVISJR
aka - Tampa.NET Koder
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:uG****************@tk2msftngp13.phx.gbl...
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.AppSett ings("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

Nov 19 '05 #4

P: n/a
Make sure the <appSettings> is placed outside of the <system.web> element.
I think it must go under the configuration element like it shows here:
http://www.dotnetjunkies.com/quickst...gretrieve.aspx
--
TDAVISJR
aka - Tampa.NET Koder
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:uG****************@tk2msftngp13.phx.gbl...
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.AppSett ings("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

Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.