L
Laura K
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
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