This topic is locked

Unique Database per Login

3/8/2019 6:01:04 PM
ASPRunner.NET General questions
P
precisiondi author

I am looking at making a site where once the user has logged in, I want to re-direct them to a different database for the information. I have added a 'dbname' field to the users table which is stored in the 'master' database. Once they log in to this, I want to then find the users 'dbname' value and connect them to that database for all other activity. I would prefer if I can setup a connection string to use in the 'users' table, but if I have to use a web.config connection string name, that would be okay too.

T
Tim 3/8/2019
P
precisiondi author 3/8/2019



Have you seen this in the help file:
https://xlinesoft.com/asprunnernet/docs/db_setconnection.htm


I have tried this, however after testing, I still see list results from the same database. I presume this only affects my own DB. calls and not the built in database connection.

admin 3/9/2019

Check this:

https://asprunner.com/forums/topic/22343-how-to-make-single-project-connect-to-different-databases-passing-database-name-via-url
This is for PHPRunner but idea is the same - read database name from the session variable.

P
precisiondi author 3/11/2019



Check this:

https://asprunner.com/forums/topic/22343-how-to-make-single-project-connect-to-different-databases-passing-database-name-via-url
This is for PHPRunner but idea is the same - read database name from the session variable.


I did see that, however I am not a PHP developer, so I am having a hard time figuring out where I put this code, and what 'sys_dbname' represents. Here is basically the code that I am trying to use in the 'After successful login' event:
strSQLExists = String.Format("select dbname from Companies where ID='{0}'",companyid);

rsExists = CommonFunctions.db_query(strSQLExists, null);

XVar rs2 = CommonFunctions.db_fetch_array(rsExists);

string dbname = rs2["dbname"];

XSession.Session["dbname"]=dbname;

DB.SetConnection(dbname);