|
-
May 23rd, 2003, 08:21 AM
#1
Thread Starter
PowerPoster
Connection String WOES
Something that I need advise on how to make more efficient is this:
When you drag and drop the design time sqlDataAdapter on let's say 10 aspx pages, .NET creates a separate connection string in the code behind for each page. Problem is when I have to move onto a production server I then need to go to each page and manually change the connection string. IT would be nice if .NET would offer a centralized class for the connection strings.
What do you suggest I do?
Thanks
-
May 23rd, 2003, 08:26 AM
#2
PowerPoster
Re: Connection String WOES
Originally posted by jesus4u
IT would be nice if .NET would offer a centralized class for the connection strings.
They do, check out the web.config file. You can store your connection string in there, as well as any other string data.
-
May 23rd, 2003, 08:34 AM
#3
in web.config in the configuration element
Code:
<appSettings>
<add key="SQLConn" value="Initial Catalog=BRS;Integrated Security=SSPI;Data Source=(local);user id=Cander;password=*****"
<add key="Watchdir" value="c:\watchdir"/>
</appSettings>
You can get the value whenever you need it:
System.Configuration.ConfigurationSettings.AppSettings("SQLConn").ToString()
-
May 23rd, 2003, 10:21 AM
#4
PowerPoster
I was to lazy to post a sample. Thanks Cander
-
May 23rd, 2003, 10:54 AM
#5
Thread Starter
PowerPoster
-
May 23rd, 2003, 11:08 AM
#6
Thread Starter
PowerPoster
Originally posted by Cander
in web.config in the configuration element
Code:
<appSettings>
<add key="SQLConn" value="Initial Catalog=BRS;Integrated Security=SSPI;Data Source=(local);user id=Cander;password=*****"
<add key="Watchdir" value="c:\watchdir"/>
</appSettings>
You can get the value whenever you need it:
System.Configuration.ConfigurationSettings.AppSettings("SQLConn").ToString()
Where exactly do I place it? Under :
Code:
<configuration>
<system.web>
-
May 23rd, 2003, 11:10 AM
#7
inside the <configuration> one but outside the <system.web> one
-
May 23rd, 2003, 11:12 AM
#8
Thread Starter
PowerPoster
I did that and tget this error:
Code:
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: This is an unexpected token. Expected 'NAME'. Line 6, position 2.
Source Error:
Line 4: <appSettings>
Line 5: <add key="SQLConn" value="data source=X-2000;initial catalog=Intranet;integrated security=SSPI;persist security info=False;workstation id=X-2000;packet size=4096"
Line 6: </appSettings>
Line 7:
Line 8: <system.web>
-
May 23rd, 2003, 11:17 AM
#9
you didnt close the <add element
put /> on the end
-
May 23rd, 2003, 11:20 AM
#10
Thread Starter
PowerPoster
-
May 23rd, 2003, 11:21 AM
#11
Dont worry over it. I did the exact same thing the first time I used that stuff and spent 3 hours trying to figure out what theheck was going on.
-
May 23rd, 2003, 11:23 AM
#12
Thread Starter
PowerPoster
You have always been helpful! Thanks
-
May 23rd, 2003, 11:27 AM
#13
Your welcome.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|