![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
| [WebMethod] |
#3
| |||
| |||
|
|
Hi Simon, From your description, I understand that you're getting some problem when try read connectionstring 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 connectionstring into webservice's main web.config such as connectionStrings add name="ConnStr" connectionString="xxxxxxxxxxxxxxx"/ /connectionStrings ** add a webmethod which will return a certain connectionString via name. e.g. [WebMethod] public string GetConnectionString(string name) { return ConfigurationManager.ConnectionStrings[name].ConnectionString; } and I get get the connectionstring 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" <none (AT) none (DOT) com 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: connectionStrings add name="ConnStr" connectionString="xxxxxxxxxxxxxxx"/ /connectionStrings Bu when I want to access the data with: coll = ConfigurationManager.ConnectionStrings; connStr = coll[0].ConnectionString; connStr = coll["ConnStr"].ConnectionString; Second line returns: "data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspn etdb.mdf;User Instance=true" And the third line return null reference exception. Why? Is it not enough to change the connectionStrings section in project and this should work? Thank you Simon |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |