Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > The ConnectionString property has not been initialized.

Reply
Thread Tools

The ConnectionString property has not been initialized.

 
 
Laura K
Guest
Posts: n/a
 
      05-08-2005
Tried all kinds of things. I get the error.

The ConnectionString property has not been initialized.



Any help appreciated.

-----------------------------------------------------------------------------------------------------
This is the web.config info

<configuration>

<appSettings>

<add key="connectionstring" value="Data Source=path to database;
database=testingsite;User Id=UserID;Password=password" />

</appSettings>

-------------------------------------------------------------------------------------------------------------------------------------------------------------------

Here is the doc mentioned in the error.



Imports System.Data.SqlClient



Public Class Catalog

Public Shared Function GetDepartments() As SqlDataReader

' Create the connection object

Dim connection As New SqlConnection(connectionString)

' Create and initialize the command object

Dim command As New SqlCommand("dbo.GetDepartments", connection)

command.CommandType = CommandType.StoredProcedure

' Open the connection

connection.Open()

' Return a SqlDataReader to the calling function

Return command.ExecuteReader(CommandBehavior.CloseConnect ion)

End Function

Private Shared ReadOnly Property connectionString() As String

Get

Return ConfigurationSettings.AppSettings("ConnectionStrin g")

End Get

End Property

End Class


 
Reply With Quote
 
 
 
 
Craig Deelsnyder
Guest
Posts: n/a
 
      05-08-2005
Laura K wrote:
> Tried all kinds of things. I get the error.
>
> The ConnectionString property has not been initialized.
>
>
>
> Any help appreciated.
>
> -----------------------------------------------------------------------------------------------------
> This is the web.config info
>
> <configuration>
>
> <appSettings>
>
> <add key="connectionstring" value="Data Source=path to database;
> database=testingsite;User Id=UserID;Password=password" />
>
> </appSettings>
>
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Here is the doc mentioned in the error.
>
>
>
> Imports System.Data.SqlClient
>
>
>
> Public Class Catalog
>
> Public Shared Function GetDepartments() As SqlDataReader
>
> ' Create the connection object
>
> Dim connection As New SqlConnection(connectionString)
>
> ' Create and initialize the command object
>
> Dim command As New SqlCommand("dbo.GetDepartments", connection)
>
> command.CommandType = CommandType.StoredProcedure
>
> ' Open the connection
>
> connection.Open()
>
> ' Return a SqlDataReader to the calling function
>
> Return command.ExecuteReader(CommandBehavior.CloseConnect ion)
>
> End Function
>
> Private Shared ReadOnly Property connectionString() As String
>
> Get
>
> Return ConfigurationSettings.AppSettings("ConnectionStrin g")
>
> End Get
>
> End Property
>
> End Class
>
>


I know the tags are case-sensitive in web.config. Can't remember about
the keys/vals values. Try changing the case sensitivity of your
..AppSettings call or the key name in the config (make them the same).

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
 
Reply With Quote
 
 
 
 
Laura K
Guest
Posts: n/a
 
      05-08-2005
I tried dozen of case changes. That doesn't seem to be it.

Any other ideas?


"Craig Deelsnyder" <cdeelsny@NO_SPAM_4_MEyahoo.com> wrote in message
news:(E-Mail Removed)...
> Laura K wrote:
>> Tried all kinds of things. I get the error.
>>
>> The ConnectionString property has not been initialized.
>>
>>
>>
>> Any help appreciated.
>>
>> -----------------------------------------------------------------------------------------------------
>> This is the web.config info
>>
>> <configuration>
>>
>> <appSettings>
>>
>> <add key="connectionstring" value="Data Source=path to database;
>> database=testingsite;User Id=UserID;Password=password" />
>>
>> </appSettings>
>>
>> -------------------------------------------------------------------------------------------------------------------------------------------------------------------
>>
>> Here is the doc mentioned in the error.
>>
>>
>>
>> Imports System.Data.SqlClient
>>
>>
>>
>> Public Class Catalog
>>
>> Public Shared Function GetDepartments() As SqlDataReader
>>
>> ' Create the connection object
>>
>> Dim connection As New SqlConnection(connectionString)
>>
>> ' Create and initialize the command object
>>
>> Dim command As New SqlCommand("dbo.GetDepartments", connection)
>>
>> command.CommandType = CommandType.StoredProcedure
>>
>> ' Open the connection
>>
>> connection.Open()
>>
>> ' Return a SqlDataReader to the calling function
>>
>> Return command.ExecuteReader(CommandBehavior.CloseConnect ion)
>>
>> End Function
>>
>> Private Shared ReadOnly Property connectionString() As String
>>
>> Get
>>
>> Return ConfigurationSettings.AppSettings("ConnectionStrin g")
>>
>> End Get
>>
>> End Property
>>
>> End Class
>>
>>

>
> I know the tags are case-sensitive in web.config. Can't remember about
> the keys/vals values. Try changing the case sensitivity of your
> .AppSettings call or the key name in the config (make them the same).
>
> --
> Craig Deelsnyder
> Microsoft MVP - ASP/ASP.NET



 
Reply With Quote
 
Patrick Olurotimi Ige
Guest
Posts: n/a
 
      05-08-2005
Try this:-
<add key="ConnectionString" value="Data Source=(local);
database=Northwind; Integrated Security=SSPI" />

MAKE SURE U ARE PASSING THE CORRECT KEY IN UR APPLICATION.

Patrick



*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
Brock Allen
Guest
Posts: n/a
 
      05-08-2005
> <add key="connectionstring" value="Data Source=path to database;
> database=testingsite;User Id=UserID;Password=password" />


When this says "path to database", what exactly is the value you're specifying?
It should be "servername" or "servername\instance".

-Brock
DevelopMentor
http://staff.develop.com/ballen




 
Reply With Quote
 
Craig Deelsnyder
Guest
Posts: n/a
 
      05-08-2005
Patrick Olurotimi Ige wrote:
> Try this:-
> <add key="ConnectionString" value="Data Source=(local);
> database=Northwind; Integrated Security=SSPI" />
>
> MAKE SURE U ARE PASSING THE CORRECT KEY IN UR APPLICATION.
>
> Patrick
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***


Heh, I blew right past that part Obviously that's pry the problem...

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
 
Reply With Quote
 
Laura K
Guest
Posts: n/a
 
      05-08-2005
When I say path to database it is remote.

sql3.webcontrolcenter.com


"Brock Allen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ...
>> <add key="connectionstring" value="Data Source=path to database;
>> database=testingsite;User Id=UserID;Password=password" />

>
> When this says "path to database", what exactly is the value you're
> specifying? It should be "servername" or "servername\instance".
>
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>
>



 
Reply With Quote
 
Patrick Olurotimi Ige
Guest
Posts: n/a
 
      05-09-2005
Brock good u figured out that issue ..
And Laura have u finally fixed the connection?
Patrick


*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
Laura K
Guest
Posts: n/a
 
      05-09-2005
Nope connection not fixed. I am also posting this on another forum. Here
is a list of docs. would love to have help. I am totally lost on this one.

Here is the exact same thing as I posted on the other forum. Any help
appreciated.

Here is the situation. I am following a book, "Beginning ASP.NET 1.1
E-Commerce. The book has me working on a local SQL server. I am working
remotly and trying to make the changes needed to do it that way.

Instead of posting code I will post a txt version of the docs.

This contains the code for the connection

http://209.200.112.194/txtdocs/catalog.vb.txt

This is a user control code behind

http://209.200.112.194/txtdocs/depar...st.ascx.vb.txt

this is the user control - view source to see the code

http://209.200.112.194/txtdocs/departmentslist.ascx.txt

web config

http://209.200.112.194/txtdocs/web.config.txt

Help???




Laura

"Patrick Olurotimi Ige" <(E-Mail Removed)> wrote in message
news:Otxjw$(E-Mail Removed)...
> Brock good u figured out that issue ..
> And Laura have u finally fixed the connection?
> Patrick
>
>
> *** Sent via Developersdex http://www.developersdex.com ***



 
Reply With Quote
 
Patrick Olurotimi Ige
Guest
Posts: n/a
 
      05-10-2005
Laura maybe you can give a try like this:-
Don't use:-
ConfigurationSettings.AppSettings("ConnectionStrin g")

Try including your connectionstring in ur code like:-

Dim connection As New SqlConnection("Data Source=SERVERNAME;Initial
Catalog=YOURDATABASE;User Id=sa;Password=asdasd;")

Hope that helps
** See how it goes**

Patrick




*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ExecuteReader: Connection property has not been initialized MattB ASP .Net 3 10-04-2007 08:09 AM
2.0: "The ConnectionString property has not been initialized." RAM ASP .Net 0 10-09-2006 01:58 PM
The printing has been stopped and this job has been add to the queu? dejola Computer Support 6 12-30-2005 03:26 AM
ExecuteReader: Connection property has not been initialized. CJM ASP .Net 2 08-17-2004 02:51 PM
ASP.net: Error "Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized." Tony ASP .Net 6 06-15-2004 09:27 AM



Advertisments