Hi Simon,
From your description, I understand that you're getting some problem when
try read connectionstrin g from configuration file of an Webservice
application ,correct?
As for the webservice application and code, would you provide some further
info? I've performed a simple test as below:
** add a connectionstrin g into webservice's main web.config such as
<connectionStri ngs>
<add name="ConnStr" connectionStrin g="xxxxxxxxxxxx xxx"/>
</connectionStrin gs>
** add a webmethod which will return a certain connectionStrin g via name.
e.g.
>>>>>>>>>>>
[WebMethod]
public string GetConnectionSt ring(string name)
{
return
ConfigurationMa nager.Connectio nStrings[name].ConnectionStri ng;
}
<<<<<<<<<
and I get get the connectionstrin g entry returned correctly. Therefore, I
wonder whether there is any particular setting difference in your
applicaiton.
Please feel free to post here if there is anything I missed.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Simon" <no**@none.co m>
Subject: Connection strings
Date: Sat, 29 Dec 2007 22:35:35 +0100
I have problems with connection strings. I have added new connection string
to Web.config:
<connectionStri ngs>
<add name="ConnStr" connectionStrin g="xxxxxxxxxxxx xxx"/>
</connectionStrin gs>
Bu when I want to access the data with:
coll = ConfigurationMa nager.Connectio nStrings;
connStr = coll[0].ConnectionStri ng;
connStr = coll["ConnStr"].ConnectionStri ng;
Second line returns:
"data source=.\SQLEXP RESS;Integrated
Security=SSPI;A ttachDBFilename =|DataDirectory |aspnetdb.mdf;U ser
Instance=true"
And the third line return null reference exception.
Why? Is it not enough to change the connectionStrin gs section in project
and
this should work?
Thank you
Simon