473,406 Members | 2,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

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
4 1794
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Devante | last post by:
Hi, I am fairly new to ASP.NET and have been working on a web form that will allow a user to upload images to a database. I have found a sample web form that I have been trying to get working,...
5
by: Fernando Lopes | last post by:
Hi there. In your opinion, where is the best place to put the connection string of a web application? Web.config, a constant into the code? I'm not using a component server, so it's not an...
10
by: Laura K | last post by:
Tried all kinds of things. I get the error. The ConnectionString property has not been initialized. Any help appreciated. ...
8
by: Ben R. | last post by:
Hi all, This is a multipart question. I’ve got an asp.net site that contains an access database. Previously, I would debug by making changes and uploading to my host. Now, I’d like to be...
2
by: tshad | last post by:
I am trying to create an application in my VS 2002 application. I took some of the code from my web page where it works fine. I can connect fine from my Sql Query Analyser to both my local Sql...
3
by: Jim Andersen | last post by:
Hi, I would appreciate if someone could explain this behaviour, and maybe offer a better solution. I have been working with the GridView control. And SqlDataSource. It works great if I do:...
5
by: Arpan | last post by:
I created a System DSN named "NETData" for a SQL Server 2005 Express database. Now to make use of this System DSN to access records in the DB table, this is how I framed the ConnectionString: ...
1
by: ginkim | last post by:
Is there a way to grab the connectionstring value from the web.config in another project? I created a DataAccess layer to store my typed dataset and it automatically created settings.settings and...
5
by: Radu | last post by:
Hi. In a repeater I have as ItemTemplate the following, among others, and everything works great: <asp:SqlDataSource ID="LocationSqlDataSource" SelectCommand="SELECT blah-blah-blah"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.