473,326 Members | 2,805 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,326 software developers and data experts.

The ConnectionString property has not been initialized

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, and the web form loads up fine but
upon submitting the image, it comes with the following error:

The ConnectionString property has not been initialized.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The ConnectionString
property has not been initialized.

Source Error:
Line 129: Try
Line 130:
Line 131: myConnection.Open()
Line 132:
Line 133:
myCommand.ExecuteNonQuery()

I found this script from the following website
http://aspalliance.com/articleViewer.aspx?aId=138&pId=

Can anyone please help I am completely lost as to how to correct this problem.
I am using Visual Studio 2005 beta 1, IIS 6.0, .NET version 2.0.40607 and
SQL Server 2000.

Any help would be greatly appreciated.

Thank,

Devante
Jul 21 '05 #1
4 46637
The exception is very clear. The ConnectionString property has not been set,
when trying to call Open the SqlConnection object.

So obviously, this property is not being set - hence the connection can't do
it's job.

Looking through the code, it looks like the connection string is being
retrieved from Web.config: Dim myConnection As New
SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))

Unless you have a ConnectionString setting in your Web.config with a valid
connection string to your database, this isn't going to work. I am guessing
you never added this setting. Did you think this source code would somehow
know how to connect to your particular sql server? You had to have somehow
specified how to connect.

"Devante" <De*****@discussions.microsoft.com> wrote in message
news:EC**********************************@microsof t.com...
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, and the web form loads up fine but
upon submitting the image, it comes with the following error:

The ConnectionString property has not been initialized.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The ConnectionString
property has not been initialized.

Source Error:
Line 129: Try
Line 130:
Line 131: myConnection.Open() Line 132:
Line 133:
myCommand.ExecuteNonQuery()

I found this script from the following website
http://aspalliance.com/articleViewer.aspx?aId=138&pId=

Can anyone please help I am completely lost as to how to correct this problem. I am using Visual Studio 2005 beta 1, IIS 6.0, .NET version 2.0.40607 and
SQL Server 2000.

Any help would be greatly appreciated.

Thank,

Devante

Jul 21 '05 #2
Sounds like you did not specify a connection string when creating your
SqlConnection object. If you copied the code from the link that you
specified then you have a line of code looking like this:

Dim myConnection As New
SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))

This indicates that whoever wrote the code put the connection string in the
appSettings section of the web.config file. If you did not do this then
ConfigurationSettings.AppSettings("ConnectionStrin g") returns null and the
SqlConnection object does not know which database to connect to. So you have
to specify your own connection string instead.

HTH, Jakob.
"Devante" wrote:
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, and the web form loads up fine but
upon submitting the image, it comes with the following error:

The ConnectionString property has not been initialized.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The ConnectionString
property has not been initialized.

Source Error:
Line 129: Try
Line 130:
Line 131: myConnection.Open()
Line 132:
Line 133:
myCommand.ExecuteNonQuery()

I found this script from the following website
http://aspalliance.com/articleViewer.aspx?aId=138&pId=

Can anyone please help I am completely lost as to how to correct this problem.
I am using Visual Studio 2005 beta 1, IIS 6.0, .NET version 2.0.40607 and
SQL Server 2000.

Any help would be greatly appreciated.

Thank,

Devante

Jul 21 '05 #3
Hi Jakob

I have created a web.config file and it does have the following info in it:

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

<appSettings />
<connectionStrings>
<add name="AppConnectionString1"
connectionString="Server=DCKUEPERS-01;Integrated
Security=True;Database=WebDev"
providerName="System.Data.SqlClient" />
</connectionStrings>

But for some reason its still not working what am I doing wrong?
Thank you,

Devante

"Jakob Christensen" wrote:
Sounds like you did not specify a connection string when creating your
SqlConnection object. If you copied the code from the link that you
specified then you have a line of code looking like this:

Dim myConnection As New
SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))

This indicates that whoever wrote the code put the connection string in the
appSettings section of the web.config file. If you did not do this then
ConfigurationSettings.AppSettings("ConnectionStrin g") returns null and the
SqlConnection object does not know which database to connect to. So you have
to specify your own connection string instead.

HTH, Jakob.
"Devante" wrote:
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, and the web form loads up fine but
upon submitting the image, it comes with the following error:

The ConnectionString property has not been initialized.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The ConnectionString
property has not been initialized.

Source Error:
Line 129: Try
Line 130:
Line 131: myConnection.Open()
Line 132:
Line 133:
myCommand.ExecuteNonQuery()

I found this script from the following website
http://aspalliance.com/articleViewer.aspx?aId=138&pId=

Can anyone please help I am completely lost as to how to correct this problem.
I am using Visual Studio 2005 beta 1, IIS 6.0, .NET version 2.0.40607 and
SQL Server 2000.

Any help would be greatly appreciated.

Thank,

Devante

Jul 21 '05 #4
The line ConfigurationSettings.AppSettings("ConnectionStrin g") will not work
with the config file you posted. Are you using this line of code? If yes,
then your config file should look like this:

<appSettings>
<add key="ConnectionString" value="..." />
</appSetting>

Or have you defined a configSection for reading the connection string? In
any case, I don't think you are reading the connection string correctly from
the config file, so you should do some debugging trying to find out what the
problem is.

Regards, Jakob.

"Devante" wrote:
Hi Jakob

I have created a web.config file and it does have the following info in it:

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

<appSettings />
<connectionStrings>
<add name="AppConnectionString1"
connectionString="Server=DCKUEPERS-01;Integrated
Security=True;Database=WebDev"
providerName="System.Data.SqlClient" />
</connectionStrings>

But for some reason its still not working what am I doing wrong?
Thank you,

Devante

"Jakob Christensen" wrote:
Sounds like you did not specify a connection string when creating your
SqlConnection object. If you copied the code from the link that you
specified then you have a line of code looking like this:

Dim myConnection As New
SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))

This indicates that whoever wrote the code put the connection string in the
appSettings section of the web.config file. If you did not do this then
ConfigurationSettings.AppSettings("ConnectionStrin g") returns null and the
SqlConnection object does not know which database to connect to. So you have
to specify your own connection string instead.

HTH, Jakob.
"Devante" wrote:
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, and the web form loads up fine but
upon submitting the image, it comes with the following error:

The ConnectionString property has not been initialized.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The ConnectionString
property has not been initialized.

Source Error:
Line 129: Try
Line 130:
Line 131: myConnection.Open()
Line 132:
Line 133:
myCommand.ExecuteNonQuery()

I found this script from the following website
http://aspalliance.com/articleViewer.aspx?aId=138&pId=

Can anyone please help I am completely lost as to how to correct this problem.
I am using Visual Studio 2005 beta 1, IIS 6.0, .NET version 2.0.40607 and
SQL Server 2000.

Any help would be greatly appreciated.

Thank,

Devante

Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: TPSreport | last post by:
I log on to the cookieless application, work within it for awhile, jump to a URL outside the application, then return to the application. As soon as a db call is required, I get the error below. ...
2
by: Kamal | last post by:
Hi everyone, I've created a user control that calls some method from a class that set the connection string, the connection string is stored in the App.Config file. When i try to add that...
5
by: josephrthomas | last post by:
hi...i am getting a error here...saying : **quote** The ConnectionString property has not been initialized. Description: An unhandled exception occurred during the execution of the current web...
6
by: Tony | last post by:
Dear All, When I run an example program on the http://www.dotnetjunkies.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/data/datagrid1.src&file=VB\datagrid1.aspx&font=3 ...
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. ...
5
by: Kent Johnson | last post by:
Hi all, I have accidentally deleted my web.config file so I'll have to recreate it. I have tried this in my Web.config file: <configuration> <appSettings> <add key="ConnectionString"...
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...
4
by: QC | last post by:
Hi, this morning found that my Service had crashed, and the error was "Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized". I have no...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.