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|aspnetdb.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
Steven Cheng[MSFT] - 31 Dec 2007 02:59 GMT
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@none.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|aspnetdb.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