Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / December 2007

Tip: Looking for answers? Try searching our database.

Connection strings?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Simon - 29 Dec 2007 21:30 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.