DSN, Storing variable permanently

Results 1 to 2 of 2

Thread: DSN, Storing variable permanently

  1. #1
    Join Date
    Dec 1969

    Default DSN, Storing variable permanently

    I have Windows 98. My two databases is set up in Control Panel, ODBC Data Sources, User DSN<BR><BR>My program will be using two databases. I am using a drop down menu for the user to pick which database to work with. Once the database is picked, they will be using it on all other pages. After selecting the database, I need to store the variable somewhere to access it on all other pages. I have used global.asa to store variables that are hardcoded in and that works find. Reading up on it, i don&#039;t see how to send a variable to global.asa to store it, or for that matter if you can.<BR><BR>Can you send a varible to global.asa to be stored and used in other pages?<BR><BR>If yes, how?<BR><BR>Should I put it in an asp include, I am going in that direction? Here is my code.<BR>------<BR>selectdatabase.asp<BR>--------<BR>&#060;%<BR>Dim gatekeeper, gkadmin<BR>gatekeeper="DSN=autovu"<BR>gkadmin="DSN =autovu2"<BR>%&#062;<BR><BR>&#060;!-- menu to pick database --&#062;<BR> &#060;form method="get" ACTION="database-var.asp"&#062; <BR> ********<BR> Database: <BR> &#060;select name="database"&#062;<BR> &#060;option value=&#060;%=gatekeeper%&#062;&#062;GateKeeper<BR > &#060;option value=&#060;%=gkadmin%&#062;&#062;GKAdmin<BR> &#060;option selected&#062;----Choose One------<BR> &#060;input type="submit" value="Submit!" &#062;<BR> &#060;/select&#062; <BR> &#060;/form&#062;<BR><BR><BR>----------<BR>database-var.asp<BR>----------<BR>&#060;%<BR><BR><BR>Dim myDSN<BR>myDSN = Request.QueryString("database")<BR>Dim objConn, objRS<BR>Set objConn = Server.CreateObject("ADODB.Connection")<BR>objConn .Open myDSN<BR>Set objRS = objConn.Execute("SELECT username FROM passwords" )<BR>Response.write username<BR><BR> %&#062;<BR><BR>1/ It seens to be selecting the database ok. There are no errers, but I am not getting anything from Response.write username<BR><BR>2/ When the database is selected, how do i store it permanently while the user goes to other pages and call it from other pages?<BR><BR>Thank you, <BR>Larry

  2. #2
    Join Date
    Dec 1969

    Default RE: DSN, Storing variable permanently

    This looks like the perfect place to use a Session variable.<BR><BR>Session("DSN")=Request.QueryStrin g("database")<BR>objConn.Open Session("DSN")<BR><BR>As long as you don&#039;t try to store a reference to the connection itself, this will work fine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts