|
-
Jul 28th, 2003, 04:52 AM
#2
Addicted Member
HI
when yu have to reuse yur sqlconnection strings do use the Configuartion files for accessing the SQlcon string.
advantages:
1. You secured yur connnection details in a central web.config file.
2. when ever yu do neeed to change yur database location , yu can just edit the sqlserver info here in the web.config file.
3. its very easy to access the sqlconn strings from pages using the appsettings tags .
in side the web.config yu have a seperate appsettings block .
inside this block yu can have a key value pair to hold the connnection string property and its value.
inside the web.cofig file::::
<configuration>
<appSettings>
<add key="constr" value="server=servername;database=dataset;uid=;pwd=;"/>
</appSettings>
</configuration>
while accessing yu can use in the aspx paeg as ::::
configurationsettings.appsettings("constr")
dim sqlconn as sqlconnection
sqlconnection.connectionstring = configurationsettings.appsettings("constr")
sqlconn.open
' after using
sqlconn.close
if yu have any further doubts pls be free to ask .
with regards
Senthil
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
|