|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
storing database connection stringsis it still customary to use web.config and global.asax to store connection
strings? For example storing the string in web.config and using application start procedure in global.asax to declare a global app variable? I'm an off and on hobby programmer and this was the last method recommended to me. As I start new projects I try to find out and follow the recommended practices of the day. Yes, that's still a good approach, you can read connection strings from
web.config using the WebConfigurationManager class. You can now also encrypt parts of web.config, which is useful if you're storing passwords. djc wrote: Show quote > is it still customary to use web.config and global.asax to store connection > strings? For example storing the string in web.config and using application > start procedure in global.asax to declare a global app variable? > > I'm an off and on hobby programmer and this was the last method recommended > to me. As I start new projects I try to find out and follow the recommended > practices of the day. I am not sure it was ever a good idea to use global.asax, as you have to
recompile to configure (not as much in 2.0, which will recompile single files on the fly, of course). The config file is still recommended, although it is a good idea to encrypt on teh machine you are going to run it on. -- Show quoteGregory A. Beamer MVP; MCP: +I, SE, SD, DBA http://gregorybeamer.spaces.live.com ************************************************* Think outside of the box! ************************************************* "djc" <no***@nowhere.com> wrote in message news:ezhdSxP%23GHA.1128@TK2MSFTNGP05.phx.gbl... > is it still customary to use web.config and global.asax to store > connection strings? For example storing the string in web.config and using > application start procedure in global.asax to declare a global app > variable? > > I'm an off and on hobby programmer and this was the last method > recommended to me. As I start new projects I try to find out and follow > the recommended practices of the day. > thank you both. Its appreciated. Just to clarify to Cowboy I meant the
combination of web.config and global.asax... actual value in web.config and declaring var referencing that value in global.asax so only web.config would need to be changed when database changes. and I will definitely check out the encryption. thanks again. Show quote "djc" <no***@nowhere.com> wrote in message news:ezhdSxP%23GHA.1128@TK2MSFTNGP05.phx.gbl... > is it still customary to use web.config and global.asax to store > connection strings? For example storing the string in web.config and using > application start procedure in global.asax to declare a global app > variable? > > I'm an off and on hobby programmer and this was the last method > recommended to me. As I start new projects I try to find out and follow > the recommended practices of the day. > Hi,
djc wrote: > thank you both. Its appreciated. Just to clarify to Cowboy I meant the I don't see why you would want to use Global.asax for the> combination of web.config and global.asax... actual value in web.config and > declaring var referencing that value in global.asax so only web.config would > need to be changed when database changes. connection-string. You can always do a ... myCn.connectionstring=ConfigurationManager.ConnectionStrings("DBCon").ConnectionString .... so there's no need to store it anywhere (i.e. in an Application-var). If you store your connection-string within web.config, you don't have to change anything *but* web.config if the connection needs to be amended. Try adding a setting like this one in your web.config: <connectionStrings> <add name="DBCon" connectionString="Provider=..."/> </connectionStrings> Cheers, Olaf thanks for the input.
Show quote "Olaf Rabbachin" <Olaf_NoSpam@IntuiDev.com> wrote in message news:us013LR%23GHA.1220@TK2MSFTNGP04.phx.gbl... > Hi, > > djc wrote: > >> thank you both. Its appreciated. Just to clarify to Cowboy I meant the >> combination of web.config and global.asax... actual value in web.config >> and >> declaring var referencing that value in global.asax so only web.config >> would >> need to be changed when database changes. > > I don't see why you would want to use Global.asax for the > connection-string. You can always do a ... > > myCn.connectionstring=ConfigurationManager.ConnectionStrings("DBCon").ConnectionString > > ... so there's no need to store it anywhere (i.e. in an Application-var). > If you store your connection-string within web.config, you don't have to > change anything *but* web.config if the connection needs to be amended. > Try adding a setting like this one in your web.config: > <connectionStrings> > <add name="DBCon" connectionString="Provider=..."/> > </connectionStrings> > > Cheers, > Olaf > -- > My .02: www.Resources.IntuiDev.com |
|||||||||||||||||||||||