Hi,
I'm trying to setup the Web Config file so that the connection string is
read from it but I'm not sure what I'm doing wrong. The error I get is:
The ConnectionString property has not been initialized.
I also tried to create a virtual path but that didn't work.
My application is at c:\inetpub\wwwroot\web This is where the web.config
file is and it contains the following:
<appSettings>
<add key="connectionstring" value="server=(local)
;trusted_connection=true;database=xxx"/>
</appSettings>
The aspx file contains:
<%@ Page Language="VB" %>
<script runat="server">
Function GetData() As System.Data.IDataReader
Dim connectionString As String
connectionString = ConfigurationSettings.AppSettings
("ConnectionString")
Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(connectionStri ng)
Dim queryString As String = "SELECT [tblLink].[quote], [tbllink]
..[linkURL"& _
"] FROM [tblink]"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
dbConnection.Open
Dim dataReader As System.Data.IDataReader =
dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
Return dataReader
End Function
Sub Page_Load(sender As Object, e As EventArgs)
Page.Databind()
End Sub
</script>
Thanks
--
Message posted via http://www.dotnetmonster.com