This topic is locked

multiple database connections?

4/29/2011 6:12:06 PM
ASPRunnerPro General questions
G
georgeb author

I am in the process of enhancing an existing ASP web app. the application each US county's data in a separate database. i will need to programmatically switch connections based on a user's selection from a dropdown. how do i accomplish this.

Sergey Kornilov admin 5/2/2011

You can add you code to AfterApplicationInitialized event to override the value of strConnection variable pointing it to another database.
Example. Pointing database connection to another database on Mondays:

if Weekday(Now()==1) then

strConnection="..."

else

strConnection="..."

end if
G
georgeb author 5/2/2011



You can add you code to AfterApplicationInitialized event to override the value of strConnection variable pointing it to another database.
Example. Pointing database connection to another database on Mondays:

if Weekday(Now()==1) then

strConnection="..."

else

strConnection="..."

end if



Now that i know the variable to set is there a way to implement this in the onclick of the menu link?

Sergey Kornilov admin 5/2/2011

You need to provide more info on how it supposed to work. What kind of links are on this menu? Do they belong to the same project?

G
georgeb author 5/3/2011



You need to provide more info on how it supposed to work. What kind of links are on this menu? Do they belong to the same project?



the menu is the menu generated by ASPRunnere.

structure:

Menu title datasource

Users - TPS_Users

Companies - TPS_Users

Counties - TPS_Users

the top three menu items maintain the user-companies-counties data and relationships. ie a user has many companies and a company can have many counties
Grand - TPS_Grand

Summit - TPS_Summit

PITKIN - TPS_Pitkin

these menu items link to the individual county data

the county specific schemas are identical so i woul like to swithch between them and display the same page with different data.
this help?

GAB

Sergey Kornilov admin 5/4/2011

A few ideas for AfterAppInitialized event:

str = Request.ServerVariables("SCRIPT_NAME")

loc = instrRev(str,"/")

str = mid(str, loc+1, len(str) - loc)
if left(str, len("Users_"))= "Users_" then

strConnection="..."

else if left(str, len("Grand_"))= "Grand_" then

strConnection="..."

else if left(str, len("Summit_"))= "Summit_" then

strConnection="..."

end if