473,378 Members | 1,084 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,378 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 46646
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.