Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9
This is the forum to discuss the Wrox book Professional ASP.NET 2.0 Special Edition by Bill Evjen, Scott Hanselman, Devin Rader, Farhan Muhammad, Srinivasa Sivakumar; ISBN: 9780470041789
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 20th, 2006, 04:35 AM
Registered User
 
Join Date: Apr 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default ConfigurationManager.ConnectionSettings.add()

Hi

i'm trying to save an connection string in the web.config file. I have coppied the code on page 352 in listing 11-13 but when i run the code i get an exception: "The configuration is read only."



  #2 (permalink)  
Old April 20th, 2006, 06:02 AM
Registered User
 
Join Date: Apr 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I looked in the code examples to the book and found the awnser.:D

  #3 (permalink)  
Old February 25th, 2007, 03:54 PM
Registered User
 
Join Date: Feb 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have the same problem and could not find the solution in the text.

"The configuration is read only."

is producted by either of the following commands:

WebConfigurationManager.ConnectionStrings.Add(newC onnString);
ConfigurationManager.ConnectionStrings.Add(newConn String);

I cannot add a new connection string at run-time.
Please help :(


Brain strain can be such a pain.
  #4 (permalink)  
Old February 25th, 2007, 08:58 PM
Authorized User
Points: 176, Level: 3
Points: 176, Level: 3 Points: 176, Level: 3 Points: 176, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2006
Location: , , .
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Please Explore this Image
As You Can See From Listing 11-13 Authors Expose the connection string for the regular SqlServer(not Express).
You Can probably receive errors because of the TWO main problems.

First: The connection String(aspx.page) Using "sa" for login, and "Password" for Password.
This means that this connection string wil work ONLY With The Full-Sql2005Server(Not-Express)

Second: Your OpenWEbConfiguration Method Doesn't see Your Project, because You simply using a different name I Use Listing 17-2 for example. so for me it goes like this:("/Listing17-2")
********************************
// Add the new connection string to the web.config
            Configuration config = System.Web.Configuration.WebConfigurationManager.O penWebConfiguration("/YourProjectNameHere");
            config.ConnectionStrings.ConnectionStrings.Add(con n);
            config.Save();

In General*** If you don't have a full-version Sql2005Server
You Will need to change the connection string in the aspx.page to the SqlExpress connection String.
**Another words(Let's say) SqlExpress is using another autentication type. No need in Sa username and password pass.
Thats why you need to change the main conn\string to sqlExpress Con\string if you using SqlExpress2005

Here what you can do without guessing what the real connectionString must be.
*Try to create Some new SqlDataSource control, and bind it to the SqlExpress2005Server.
*After binding it to the server, it will automaticaly create a conn\string for you in the web.config file.[no need to guess!]
*Then you can explore your conn\string presented in the web.config file.
*After doing this simply go back to your aspx.page and change the connectionString according to your new Connection String in the web.config file.
You will probably understand which changes to add to the connection string in your aspx.page.
You will add an MachineKey/SQLEXPRESS..se the rest of the code in Web.config. and so on...
**Basically You will change only the ConnectionString Line.
 and the conn.Name + connProviderName will still the same.
I think you get the idea of this.
Refer to the Image above and explore the SqlExpressConnection String.
The truth is, the SqlExpress and SqlServer2005 conn\strings looks pretty much the same. you will see from the image wich lines of code to change to flip it to Express compatible. this is very easy to do.
Refer to Image, for mor clear understanding. It's not that hard I promise :)

*Finally After running the code, you will receive Blank Html Page.
Simply close this Page, and go back to your VisualStudio. this DialogWindow will PopUp. Simply click YesToAll Button. and go to your Web.config file.the new created connectionString will appear in the web.config file.

Explore the Image carefully, this is very easy to FIX. you will understand how this works in a second. I had tested Listing 11-13 in both SqlExpress2005Server and the full-Sql2005Server
Works fine in both.
I hope this explanation will help to solve your problem.
Take care!
 


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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Add subhasps8 ASP.NET 2.0 Basics 1 March 28th, 2008 12:07 PM
can we use Configuration, ConfigurationManager in remya1000 .NET Framework 1.x 1 February 20th, 2008 09:18 AM
Add a CDATA section; add nodeset to CDATA section kssudhish XSLT 3 January 3rd, 2008 07:13 AM
12-1 ConfigurationManager shysusan BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 5 February 13th, 2007 12:42 AM
Add Push button or Check Box in outlook add-ins capdevs VS.NET 2002/2003 0 January 7th, 2006 08:51 AM



All times are GMT -4. The time now is 04:56 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.