HighTechTalks DotNet Forums  

Connection strings?

Dotnet Framework (Webservices) microsoft.public.dotnet.framework.webservices


Discuss Connection strings? in the Dotnet Framework (Webservices) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Simon
 
Posts: n/a

Default Connection strings? - 12-29-2007 , 04:30 PM






I have created new web service and inserted connection strings to web.config
file:

<connectionStrings>
<add name="ConnStr" connectionString="XXXXXXXX"/>
</connectionStrings>

When I try to read this connection string:

coll = ConfigurationManager.ConnectionStrings;
connStr = coll[0].ConnectionString;
connStr = coll["ConnStri"].ConnectionString;

coll has only one member and that one has ConnectionString value:
"data source=.\SQLEXPRESS;Integrated
Security=SSPI;AttachDBFilename=|DataDirectory|aspn etdb.mdf;User
Instance=true"

If I try to read the "ConnStr" value I get null reference exception.

Why is that? Is it not enough to change the Web.config file in project and
that should work?

Thank you

Simon


Reply With Quote
  #2  
Old   
Steven Cheng[MSFT]
 
Posts: n/a

Default RE: Connection strings? - 12-30-2007 , 09:59 PM






Hi Simon,

I have seen your another thread on this issue in the same newsgroup. I've
replied you there. Welcome to followup and continue to discuss in that
thread.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Simon" <none (AT) none (DOT) com>
Subject: Connection strings?
Date: Sat, 29 Dec 2007 22:30:10 +010

I have created new web service and inserted connection strings to
web.config
file:

<connectionStrings>
<add name="ConnStr" connectionString="XXXXXXXX"/>
</connectionStrings>

When I try to read this connection string:

coll = ConfigurationManager.ConnectionStrings;
connStr = coll[0].ConnectionString;
connStr = coll["ConnStri"].ConnectionString;

coll has only one member and that one has ConnectionString value:
"data source=.\SQLEXPRESS;Integrated
Security=SSPI;AttachDBFilename=|DataDirectory|aspn etdb.mdf;User
Instance=true"

If I try to read the "ConnStr" value I get null reference exception.

Why is that? Is it not enough to change the Web.config file in project and
that should work?

Thank you

Simon



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.