Stuck on WebConfigurationManager

  • Thread starter Thread starter Jonathan Crawford
  • Start date Start date
J

Jonathan Crawford

Hi

I have been using 1.1 .Net for ages but have moved to 2.0 on VS2008

I added a connection to the wb config file
eg like
<connectionStrings>
<add name="Pubs"
connectionString="Server=(local)\SQLExpress;Integrated
Security=True;Database=pubs;Persist Security Info=True"
providerName="System.Data.SqlClient" />
</connectionStrings>

I have a class
In my class I try and access this connection string using the following
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Imports System.Configuration
Imports System.Web.Configuration

I have referenced system web configuration and System.Configuration.dll

WHen i try to pick up the value
Private _connectionString As String =
WebConfigurationManager.ConnectionStrings["SQLConnectionString"].ConnectionString

However under the " before SQLConnectionStringis highlighted and "Identifier
is required" and the thing won't compile.

I am truly stuck and my head is about to explode
How can somethign so simple be so difficult

any help appreciated

jc
 
Back
Top