[thelist] storing connection strings in application variables

Howard Cheng howcheng at ix.netcom.com
Thu Jan 24 11:55:19 CST 2002


Just wondering why you can't have two different connection strings in two 
different application variables.

Application("CONN_STR_1") = "DSN=dsn1; UID=...; PWD=..."
Application("CONN_STR_2") = "DSN=dsn2; UID=...; PWD=..."

And then just open the connection using the appropriate connection string. 
It seems much easier than switching the connection string variable and 
hoping that the right user will get the right string. If you have to call a 
function before you open the connection to get the correct one anyway, you 
might as well just store them in separate variables.

Storing these items in application variables is a good way to go. You can 
of course use included files as others have suggested, but I figure that 
application variables are designed exactly to store data you need that's 
consistent your entire site, so why not use them.

At 10:51 AM 1/24/2002 -0500, Chris Blessing wrote:
>What I have is a development server and a live server.  Because the machines
>are different I have stored the connection string as an application-level
>variable (application("connStr")).  Depending on the serverNode application
>var (I have this stored in each server's global.asa), this connection string
>is setup with a different IP for the data source.  Within the db server
>we're using two databases, one called "orders" and one called "products".  I
>sometimes need to switch from one to the other depending on the page (like
>one page shows our products and one shows your order history, for example)
>and some pages end up using both.  I do this by calling a function I wrote
>to manipulate the "initial catalog" portion of the connection string and
>then opening the connection object as necessary.
>
>Now the issue I face is this:  should I be doing this on an application
>variable level?  If one user comes to the site while another user is on the
>site and requests an order page at the same time as the other user requests
>a product page, wouldn't that cause a "conflic of interest" in updating the
>connStr?  One person might get the page they want while the other gets an
>error (since the data source wasn't updated and that page explicitly uses
>that data source).  If I was to store the connection string in a session
>variable that would keep things separate on a user-by-user basis and
>eliminate this problem of cross-updating the connection string correct?

::::::::::::::::::::::
Howard Cheng
howcheng at ix.netcom.com
AIM: bennyphoebe
ICQ: 47319315





More information about the thelist mailing list