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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Database - Production - Test

Status
Not open for further replies.

bloise

Programmer
Jun 21, 2001
67
US
We have a login panel that allows entry to our system. I updated the panel with two radio buttons(Production/Test). What I am trying to do is set my datasource to what was selected. The datasource is originally set in my application.cfm module...

<cfset #ODBC_DataSource# = &quot;envrion&quot;>

In my login module, I would like to change this based on
the radio selection.

Example...
<cfif isDefined('theDatabase')>
<cfif #theDatabase# IS &quot;Test&quot;>
<cfset #ODBC_DataSource# = &quot;test&quot;>
<cfelse>
<cfset #ODBC_DataSource# = &quot;environ&quot;>
</cfif>
</cfif>

I now I am going into the code, but am not pointing to the test environment.

Any ideas??
Thanks,
Mike




 
Your going to have to set the value in the form to some type of variable that will work on the entire site (session, client, application, etc...). This looks like you're just creating a local variable (why do you have pound signs around the variable names?), which won't work on any page except this one.

You'll need something like:
Code:
<cfif isDefined('theDatabase')>
  <cfif theDatabase IS &quot;Test&quot;>
    <cfset Session.ODBC_DataSource = &quot;test&quot;>   
   <cfelse>
     <cfset Session.ODBC_DataSource  = &quot;environ&quot;>
  </cfif>
</cfif>
Of course, you're going to have to change the name of your datasource in all of your queries to Session.ODBC_DataSource for this to work, so you may want to try something like:
Code:
<cfset ODBC_DataSource = Session.ODBC_DataSource>
But you'll still have to find a central location to put this line of code so every page can reference it.



Hope This Helps!

Ecobb

&quot;Alright Brain, you don't like me, and I don't like you. But lets just do this, and I can get back to killing you with beer.&quot; - Homer Simpson
 
Ecobb,

Thanks with the quick reply. I guess what I am really doing is setting my datasource in an application variable. What I need to do is clear this and reset it if the user changes the database.

Mike
 
Ecobb,

After reading a little, the application.cfm always gets called. What I was doing was setting the datasource in a &quot;local variable&quot; not an application variable. Starting to make sense now...

Thanks for the help
Mike
 
in you're query you're syntax looks like:

<query name = &quot;myQuery&quot; datasource = &quot;#ODBC_DataSource#&quot;>

and not
<query name = &quot;myQuery&quot; datasource = &quot;environ&quot;>

right?

thereptilian120x120.gif
 
Thanks for concern, I figured it out. I had everything set up ok in the admin part. However, did not release that the application.cfm module gets called every time. I had write some code to handle the switching of the db in my main index.html.

Thanks...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top