Showing posts with label connectionstring. Show all posts
Showing posts with label connectionstring. Show all posts

Monday, March 26, 2012

The connection name ConnectionString was not found in the applications configuration or th

Hi All, I need help. I am developing a very simple ASP.NET Application that retreived some information from an Oracle Database.

The application was working fine, but suddenly it stopped working with the following exception:

"The connection name 'ConnectionString' was not found in the applications configuration or the connection string is empty."

Furthermore, I had backups of the application on my hard drive, and all suddenly stopped working with the same exception. I beieve it is a general Configuration issue ... because all the connections are failing with the same exception.

Following is the excepton, and the line where the exception is given:

Line 55:
Line 56:
Line 57: <asp:SqlDataSource ID="SqlDataSource42" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString42%>"
Line 58: ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
Line 59: SelectCommand="Select * from TBORDER_ACTION where customer_id = 'XYZ'">

And again the exception is "The connection name 'ConnectionString' was not found in the applications configuration or the connection string is empty."

Following is my Web.config:

<?xmlversion="1.0"?><!--

Note: As an alternative to hand editing this file you can use the

web admin tool to configure settings for your application. Use

the Website->Asp.Net Configuration option in Visual Studio.

A full list of settings and comments can be found in

machine.config.comments usually located in

\Windows\Microsoft.Net\Framework\v2.x\Config

-->

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

<connectionStrings>

<addname="ConnectionString42"connectionString="Data Source=DatabaseInstance;User ID=Username42;Password=Password42;Unicode=True"providerName="System.Data.OracleClient" />

<addname="ConnectionString42m"connectionString="Data Source=DatabaseInstance;User ID=Username;Password=Password42;Unicode=True"

providerName="System.Data.OracleClient" />

</connectionStrings>

<system.web>

<!--

Set compilation debug="true" to insert debugging

symbols into the compiled page. Because this

affects performance, set this value to true only

during development.

Visual Basic options:

Set strict="true" to disallow all data type conversions

where data loss can occur.

Set explicit="true" to force declaration of all variables.

-->

<compilationdebug="true"strict="false"explicit="true"/>

<pages>

<namespaces>

<clear/>

<addnamespace="System"/>

<addnamespace="System.Data"/>

<addnamespace="System.Collections"/>

<addnamespace="System.Collections.Specialized"/>

<addnamespace="System.Configuration"/>

<addnamespace="System.Text"/>

<addnamespace="System.Text.RegularExpressions"/>

<addnamespace="System.Web"/>

<addnamespace="System.Web.Caching"/>

<addnamespace="System.Web.SessionState"/>

<addnamespace="System.Web.Security"/>

<addnamespace="System.Web.Profile"/>

<addnamespace="System.Web.UI"/>

<addnamespace="System.Web.UI.WebControls"/>

<addnamespace="System.Web.UI.WebControls.WebParts"/>

<addnamespace="System.Web.UI.HtmlControls"/>

</namespaces>

</pages>

<!--

The <authentication> section enables configuration

of the security authentication mode used by

ASP.NET to identify an incoming user.

--> <authenticationmode="Windows"/>

<!--

The <customErrors> section enables configuration

of what to do if/when an unhandled error occurs

during the execution of a request. Specifically,

it enables developers to configure html error pages

to be displayed in place of a error stack trace.

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">

<error statusCode="403" redirect="NoAccess.htm" />

<error statusCode="404" redirect="FileNotFound.htm" />

</customErrors>

--> </system.web>

</configuration>

Please help; I have been stuck with this issue for 1 week...

You have two connections strings with the same name. Is that the problem?


No - I have 2 connection string with 2 different names.

Please advice,

Mahdi


Line 57: <asp:SqlDataSource ID="SqlDataSource42" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString42%>"
Line 58: ProviderName="<%$ ConnectionStrings:ConnectionString42.ProviderName %>"



Dear jfmccarthy,

You are number 1; You are the best. I have been trying 3 days to find an answer, explored many sites, and spent more than 30 hours but could not find the answer.

Your suggestion was correct. I want to realyyyy... thank you, and wish you much success in your life (Although I am sure you are successfull).

Thanks Thanks Thanks...Big Smile


Well thank you very muchEmbarrassed

The ConnectionString property has not been initialized

Hi, I am trying to run some code I got off from the Quickstart tutorial for connecting to an Access database. I have been attempting several different methods from several different tutorials, none of which have been successful.

Here is the code that I have used which gave me the error: "The ConnectionString property has not been initialized" The complete error message is posted below the code.


<%@dotnet.itags.org. Import Namespace="System.Data" %>
<%@dotnet.itags.org. Import Namespace="System.Data.SqlClient" %
<html>
<script language="VB" runat="server"
Sub Page_Load(Sender As Object, E As EventArgs)

Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter

MyConnection = New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("PubsString"))
MyCommand = New SqlDataAdapter("select * from Release_of_Information", MyConnection)

DS = new DataSet()
MyCommand.Fill(ds, "Release_of_Information")

MyDataGrid.DataSource=ds.Tables("Release_of_Information").DefaultView
MyDataGrid.DataBind()
End Sub

</script

Below is the complete error message.

I made a change to the web.cnfg file, as is stated below, and all that I got was even less functionality (okay, no functionality) from the webserver.

any ideas ?

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:

The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

<%@dotnet.itags.org. Page Language="C#" Debug="true" %
or:

2) Add the following section to the configuration file of your application:

<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configurationTry adding a Trace.Write (or a response.write) to see what your application sees as the configuration string - like:
Trace.Write("Config = " & ConfigurationSettings.AppSettings("PubsString"))

see what's really happening there - - it looks like, at first glance, that it merely doesn't find a viable connection string there.
Check out this link:

http://www.connectionstrings.com/
With my code now looking like this:

<configuration>
<appSettings>
<add key="PubsString" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\C:\mikep\Career_Start\Career_Start.mdb;User Id=admin;Password=;" />
</appSettings>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration
<%@dotnet.itags.org. Import Namespace="System.Data" %>
<%@dotnet.itags.org. Import Namespace="System.Data.SqlClient" %
<html>
<script language="VB" runat="server"
Sub Page_Load(Sender As Object, E As EventArgs)
Trace.Write("Config = " & ConfigurationSettings.AppSettings("PubsString"))
Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter

MyConnection = New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("PubsString"))
MyCommand = New SqlDataAdapter("select * from Release_of_Information", MyConnection)

DS = new DataSet()
MyCommand.Fill(ds, "Release_of_Information")

MyDataGrid.DataSource=ds.Tables("Release_of_Information").DefaultView
MyDataGrid.DataBind()
End Sub

</script
<body

I am still getting "The ConnectionString property has not been initialized" error message.

I will be glad if I can get beyond this...
your code in web.config looks fine to me just check that you are using the same username and password as you have specified.

Also try changing this the following line:


MyConnection = New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("PubsString"))

TO

string ConnectionString = (string) ConfigurationSettings.AppSettings["PubsString"];
SqlConnection myConnection = new SqlConnection(ConnectionString);

The ConnectionString property has not been initialized

hi

i'm using the register.aspx just to enter data, and i'm not using the code for cookies so my code when preesing register button (note i'm using instead of customer , auther)

Sub Button1_Click(sender As Object, e As EventArgs)

' Only attempt a login if all form fields on the page are valid

If Page.IsValid = True Then

' Add New Customer to CustomerDB database
Dim accountSystem As ASPNET.StarterKit.Commerce.AutherregisterDB = New ASPNET.StarterKit.Commerce.AutherregisterDB()

Dim Autherid_table as String = accountSystem.AddAuther(Name.Text, Email.Text, Password.Text)

End If

End Sub
and i'm using same classess and declare connection string in webconfig localhost

but i'm getting the error message after filling the register form textboxes

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 15: Line 16:Line 17: Dim Autherid_table as String = accountSystem.AddAuther(Name.Text, Email.Text, Password.Text)Line 18: Line 19:

Source File:E:\AbdCommerce\Autherregfrm.aspx Line:17
Stack Trace:
[InvalidOperationException: The ConnectionString property has not been initialized.] System.Data.SqlClient.SqlConnection.Open() +432 ASPNET.StarterKit.Commerce.AutherregisterDB.AddAuther(String fullName, String email, String password) +380 ASP.Autherregfrm_aspx.Button1_Click(Object sender, EventArgs e) in E:\AbdCommerce\Autherregfrm.aspx:17 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +83 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain() +1277
is there any idea for the cause??

thanks

When you use web config to store setting strings, you need to import namespace System.Configuration. Why did you see the error on the codeDim Autherid_table as String = accountSystem.AddAuther(Name.Text, Email.Text, Password.Text)?Because the code call a classs that does function to add auther. So, try to go to the class file to add System.Configuration namespace.

The ConnectionString property has not been initialized

Hi all,

I have developed a web page using asp.net. When testing ( debugging ) it from the VS 2005 it works properly.

In the load of the page I created a SqlConnection and specified the ConnectionString

The problem is when calling the page from a Fox Pro 9.0 application I get this message:

The ConnectionString property has not been initialized.

It seems that when calling the page from Fox Pro the ConnectionString is written incorrectly in the load method of the page

So does anyone have any suggestion?

Regards

Could you please specify the connection string over here. Also make sure that you have used new keyword while defining the connection string

Regards,

Suhas


Hi,

There is a article onconnection string here.

The ConnectionString property has not been initialized.

I am trying to use a connection string from web.config file for the first time. Here is my code.

Try
Dim cmd As String = _
("SELECT [Name], BirthDate, StartDate From " & _
"Employees WHERE PayGroup='20' AND Status='A'")

Dim conn As String = _
System.Configuration. _
ConfigurationManager. _
AppSettings("myConString")

Dim myConn As New SqlConnection(conn)
Dim myCmd As New SqlDataAdapter(cmd, myConn)
Dim ds As New DataSet
myCmd.Fill(ds)
gvEmp.DataSource = ds
gvEmp.DataBind()

Catch ex As Exception
Response.Write(ex.Message & "<br>")
Finally

End Try

I am getting The ConnectionString property has not been initialized. What am I doing wrong?Show your web.config code.
<connectionStrings>
<add name="myConString" connectionString="Data Source=myServer;Initial Catalog=Employees;User ID=myUser;Password=mypass"
providerName="System.Data.SqlClient" />
</connectionStrings>

The ConnectionString property has not been initialized.

I have searched the threads for this but nothing seems to answer my questions. I am doing a tutorial

I am getting the error :

The ConnectionString property has not been initialized.

[InvalidOperationException: The ConnectionString property has not been initialized.]
System.Data.SqlClient.SqlConnection.Open() +433
jokepoint.Catalog.GetDepartments() in C:\MyCommerceSite\JokePoint\BusinessObjects\Catalog.vb:11
jokepoint.DepartmentsList.Page_Load(Object sender, EventArgs e) in C:\MyCommerceSite\JokePoint\UserControls\DepartmentsList.ascx.vb:31
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Page.ProcessRequestMain() +750

Here are the relevant docs.

web.config

<?xmlversion="1.0"encoding="utf-8"?>
<configuration>
<appSettings>
<addkey="ConnectionString"value="data source=sql3.webcontrolcenter.com; Initial Catalog=dbname;User ID=*******;Password=*******"/>
</appSettings>
<system.web>
<customErrorsmode="Off"/>
<globalizationrequestEncoding="utf-8"responseEncoding="utf-8"/>
</system.web>
</configuration>

Catalog.vb

Imports System.Data.SqlClient

PublicClass Catalog

PublicSharedFunction GetDepartments()As SqlDataReader
' Create the connection object
Dim connectionAsNew SqlConnection("ConnectionString")
' Create and initialize the command object
Dim commandAsNew SqlCommand("GetDepartments", connection)
command.CommandType = CommandType.StoredProcedure
' Open the connection
connection.Open()
' Return a SqlDataReader to the calling function
Return command.ExecuteReader(CommandBehavior.CloseConnection)
EndFunction

PrivateSharedReadOnlyProperty connectionString()AsString
Get
Return ConfigurationSettings.AppSettings("ConnectionString")
EndGet
EndProperty
EndClass

Anyone have any ideas?

Yea- first of all, you are using way way too much excess code...
Try completely removing this:


PrivateSharedReadOnlyProperty connectionString()AsString
Get
Return ConfigurationSettings.AppSettings("ConnectionString")
EndGet
EndProperty
EndClass



And replacing this:


' Create the connection object
Dim connectionAsNew SqlConnection("ConnectionString")


With this:


' Create the connection object
Dim connectionAsNew SqlConnection( ConfigurationSettings.AppSettings("ConnectionString") )


And you should be just fine...

OK Here is the new document. No change. Ideas?

Imports System.Data.SqlClient

PublicClass Catalog

PublicSharedFunction GetDepartments()As SqlDataReader

' Create the connection object

Dim connectionAsNew SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

' Create and initialize the command object

Dim commandAsNew SqlCommand("GetDepartments", connection)

command.CommandType = CommandType.StoredProcedure

' Open the connection

connection.Open()

' Return a SqlDataReader to the calling function

Return command.ExecuteReader(CommandBehavior.CloseConnection)

EndFunction

EndClass


Hi there,

Are you still getting any error messages ??

If yes, can you post the exact error message

Cheers!

You can see the error yourself here

http://209.200.112.194/default.aspx

Here is a cut and paste

Server Error in '/' Application.

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:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:
[InvalidOperationException: The ConnectionString property has not been initialized.] System.Data.SqlClient.SqlConnection.Open() +433 jokepoint.Catalog.GetDepartments() in C:\MyCommerceSite\JokePoint\BusinessObjects\Catalog.vb:11 jokepoint.DepartmentsList.Page_Load(Object sender, EventArgs e) in C:\MyCommerceSite\JokePoint\UserControls\DepartmentsList.ascx.vb:31 System.Web.UI.Control.OnLoad(EventArgs e) +67 System.Web.UI.Control.LoadRecursive() +35 System.Web.UI.Control.LoadRecursive() +98 System.Web.UI.Control.LoadRecursive() +98 System.Web.UI.Page.ProcessRequestMain() +750


Did you import System.Configuration ?
And what code do you have in your Page_Load?

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/departmentslist.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 K


yea, it's just like I thought. you have to Import System.Configuration into the filehttp://209.200.112.194/txtdocs/catalog.vb.txt

Imports.system.configuration

didn't work


Thats because if you wrote it like that, you didnt write it correctly
In that file the 1st line is:


Imports System.Data.SqlClient


And you just need to add the 2nd line here...


Imports System.Data.SqlClient
Imports System.Configuration



I wrote it correctly in my doc.

Didn't work!


post all of your code in the page that is getting the error so we can see what might be wrong...

LKnomad wrote:

Dim connectionAsNew SqlConnection("ConnectionString")
' Create and initialize the command object
Dim commandAsNew SqlCommand("GetDepartments", connection)
command.CommandType = CommandType.StoredProcedure
' Open the connection
connection.Open()
' Return a SqlDataReader to the calling function
Return command.ExecuteReader(CommandBehavior.CloseConnection)
EndFunction

PrivateSharedReadOnlyProperty connectionString()AsString
Get
Return ConfigurationSettings.AppSettings("ConnectionString")
EndGet
EndProperty
EndClass

Hi,

personally I think you don't access your property the way you coded it.

Try changing this line:

Dim connectionAsNew SqlConnection("ConnectionString")

with this one:

Dim connectionAsNew SqlConnection(connectionString)

Also take a look at this tutorial:Store Your Database Connection String in Web.Config...

Grz, Kris.


The page that is getting the error is the default.aspx page. This page contains a dynamic user control which I believe is the culprit because when I remove this control the page loads. The user control has an ascx and an ascx.vb. I have also posted them. Lastly there is one more doc which has the connection info.

The default page is on the root.

The user control docs are in a folder called UserControls

The doc with the connection info is in a folder called businessObjects.

The web config is on the root.

Here are links to txt files of all the code. Easier to read this way.

Below is the doc in the businessObjects folder containing all the connection info. Notice I have added the imports as suggested.

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

The two docs in the UserControl folder.

http://209.200.112.194/txtdocs/departmentslist.ascx.txt (view source for the full code)

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

Here are the docs on the root. This first doc is the default doc where I am getting the error.

http://209.200.112.194/txtdocs/default.aspx.txt

http://209.200.112.194/txtdocs/default.aspx.vb.txt (code behind)

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

I have emailed the author of this tutorial to see if he will offer any support as well.

Thanks

Laura K


Tried the change earlier and tried again just now.

No luck.

Thanks

Laura

The ConnectionString property has not been initialized.

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.CloseConnection)
End Function
Private Shared ReadOnly Property connectionString() As String
Get
Return ConfigurationSettings.AppSettings("ConnectionString")
End Get
End Property
End ClassLaura 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.CloseConnection)
> End Function
> Private Shared ReadOnly Property connectionString() As String
> Get
> Return ConfigurationSettings.AppSettings("ConnectionString")
> 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
I tried dozen of case changes. That doesn't seem to be it.
Any other ideas?
"Craig Deelsnyder" <cdeelsny@dotnet.itags.org.NO_SPAM_4_MEyahoo.com> wrote in message
news:O4c2gb2UFHA.3584@dotnet.itags.org.TK2MSFTNGP14.phx.gbl...
> Laura K wrote:
> 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
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.examnotes.net ***
> <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 specifyi
ng?
It should be "servername" or "servername\instance".
-Brock
DevelopMentor
http://staff.develop.com/ballen
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.examnotes.net ***
Heh, I blew right past that part :) Obviously that's pry the problem...
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
When I say path to database it is remote.
sql3.webcontrolcenter.com
"Brock Allen" <ballen@dotnet.itags.org.NOSPAMdevelop.com> wrote in message
news:680347632511475258348832@dotnet.itags.org.msnews.microsoft.com...
> 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
>
>
Brock good u figured out that issue ..
And Laura have u finally fixed the connection?
Patrick
*** Sent via Developersdex http://www.examnotes.net ***
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/depa...ist.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" <naijacoder@dotnet.itags.org.hotmail.com> wrote in message
news:Otxjw$EVFHA.2616@dotnet.itags.org.TK2MSFTNGP14.phx.gbl...
> Brock good u figured out that issue ..
> And Laura have u finally fixed the connection?
> Patrick
>
> *** Sent via Developersdex http://www.examnotes.net ***
Laura maybe you can give a try like this:-
Don't use:-
ConfigurationSettings.AppSettings("ConnectionString")
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.examnotes.net ***

The ConnectionString property has not been initialized.

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("ConnectionString")

End Get

End Property

End ClassLaura 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("ConnectionString")
> 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
I tried dozen of case changes. That doesn't seem to be it.

Any other ideas?

"Craig Deelsnyder" <cdeelsny@dotnet.itags.org.NO_SPAM_4_MEyahoo.com> wrote in message
news:O4c2gb2UFHA.3584@dotnet.itags.org.TK2MSFTNGP14.phx.gbl...
> 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("ConnectionString")
>>
>> 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
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 ***
> <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
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
When I say path to database it is remote.

sql3.webcontrolcenter.com

"Brock Allen" <ballen@dotnet.itags.org.NOSPAMdevelop.com> wrote in message
news:680347632511475258348832@dotnet.itags.org.msnews.microsoft.com ...
>> <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
>
Brock good u figured out that issue ..
And Laura have u finally fixed the connection?
Patrick

*** Sent via Developersdex http://www.developersdex.com ***
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/depa...ist.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" <naijacoder@dotnet.itags.org.hotmail.com> wrote in message
news:Otxjw$EVFHA.2616@dotnet.itags.org.TK2MSFTNGP14.phx.gbl...
> Brock good u figured out that issue ..
> And Laura have u finally fixed the connection?
> Patrick
>
> *** Sent via Developersdex http://www.developersdex.com ***
Laura maybe you can give a try like this:-
Don't use:-
ConfigurationSettings.AppSettings("ConnectionString")

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 ***
"Patrick Olurotimi Ige" <naijacoder@dotnet.itags.org.hotmail.com> wrote in message
news:%23c%23Rn4PVFHA.3868@dotnet.itags.org.TK2MSFTNGP14.phx.gbl...
> Laura maybe you can give a try like this:-
> Don't use:-
> ConfigurationSettings.AppSettings("ConnectionString")
> 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 ***