J
Jon Paal
..net 2.0
can't retrieve connection string from web.config, always returns error message -- what's missing ??
======web.config =========
<appSettings>
<connectionStrings>
<add name="NorthwindConn"
connectionString="Server='local'; database='NORTHWIND'; Trusted_Connection=False; uid=sa;pwd=*****"
providerName="System.Data.SqlClient" />
</connectionStrings>
</appSettings>
========== class =========
Imports System.Web
Imports System.Data
Imports System.Data.SqlClient
Imports System.Drawing
Imports System.Data.OleDb
Imports Microsoft.VisualBasic
Imports System.Configuration
Imports System.Web.Configuration
Imports System.IO
Public Class SyndicateHandler
Implements IHttpHandler
Private _errorMessage As String = String.Empty
Public Sub ProcessRequest(context As HttpContext) _
Implements System.Web.IHttpHandler.ProcessRequest
Dim sReturn As String = String.Empty
Dim sConn As String = String.Empty
try
' Get the ConnectionStrings collection.
Dim connections As ConnectionStringSettingsCollection = _
ConfigurationManager.ConnectionStrings
sConn = connections("NorthwindConn").ConnectionString
sReturn &= sConn
catch ex As Exception
sReturn &= ex.Message
end try
.....
End Sub 'ProcessRequest
End Class
can't retrieve connection string from web.config, always returns error message -- what's missing ??
======web.config =========
<appSettings>
<connectionStrings>
<add name="NorthwindConn"
connectionString="Server='local'; database='NORTHWIND'; Trusted_Connection=False; uid=sa;pwd=*****"
providerName="System.Data.SqlClient" />
</connectionStrings>
</appSettings>
========== class =========
Imports System.Web
Imports System.Data
Imports System.Data.SqlClient
Imports System.Drawing
Imports System.Data.OleDb
Imports Microsoft.VisualBasic
Imports System.Configuration
Imports System.Web.Configuration
Imports System.IO
Public Class SyndicateHandler
Implements IHttpHandler
Private _errorMessage As String = String.Empty
Public Sub ProcessRequest(context As HttpContext) _
Implements System.Web.IHttpHandler.ProcessRequest
Dim sReturn As String = String.Empty
Dim sConn As String = String.Empty
try
' Get the ConnectionStrings collection.
Dim connections As ConnectionStringSettingsCollection = _
ConfigurationManager.ConnectionStrings
sConn = connections("NorthwindConn").ConnectionString
sReturn &= sConn
catch ex As Exception
sReturn &= ex.Message
end try
.....
End Sub 'ProcessRequest
End Class