Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DSN, Storing variable permanently 1

Status
Not open for further replies.

thunderain

Programmer
Jan 10, 2002
40
CA
I have Windows 98. My two databases is set up in Control Panel, ODBC Data Sources, User DSN

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't see how to send a variable to global.asa to store it, or for that matter if you can.

Can you send a varible to global.asa to be stored and used in other pages?

If yes, how?

Should I put it in an asp include, I am going in that direction? Here is my code.
------
selectdatabase.asp
--------
<%
Dim gatekeeper, gkadmin
gatekeeper=&quot;DSN=autovu&quot;
gkadmin=&quot;DSN=autovu2&quot;
%>

<!-- menu to pick database -->
<form method=&quot;get&quot; ACTION=&quot;database-var.asp&quot;>
        
Database:
<select name=&quot;database&quot;>
<option value=<%=gatekeeper%>>GateKeeper
<option value=<%=gkadmin%>>GKAdmin
<option selected>----Choose One------
<input type=&quot;submit&quot; value=&quot;Submit!&quot; >
</select>
</form>


----------
database-var.asp
----------
<%


Dim myDSN
myDSN = Request.QueryString(&quot;database&quot;)
Dim objConn, objRS
Set objConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
objConn.Open myDSN
Set objRS = objConn.Execute(&quot;SELECT username FROM passwords&quot; )
Response.write username

%>

1/ It seens to be selecting the database ok. There are no errers, but I am not getting anything from Response.write username

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?

Thank you,
Larry
 
Easiest solution here would be to just use a session variable to store their choice:

session(&quot;db&quot;) = &quot;theDatabase&quot;

Then, on any page you need it, you just ask for:

session(&quot;db&quot;)

to retrieve their choice.
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top