This topic is locked
[SOLVED]

 select DataBase over URL

10/19/2015 11:18:23 AM
ASPRunnerPro General questions
G
gonzalosb author

Q: I have created a script that works, but it is assigned to just one database. I have a number of identical databases on same server, and would like to assign each one when they login. Is there a way to do that? table names are all the same.
the solution I found it here:PHP topic link but is for PHP, not ASP

if($_GET["dbname"])

$_SESSION["dbname"]=$_GET["dbname"];
$host="localhost";

$user="root";

$pwd="";

$port="";

$sys_dbname=$_SESSION["dbname"];


can someone help me to translate this for ASP using MS Access? i really appreciate any help on this
thank you

G
gonzalosb author 10/27/2015

I modify DBCONNECTION.ASP in a way that can be variable base on a SESSION
ORIGINAL

<%
strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Server.MapPath("db\database1.accdb") & ";Jet OLEDB:Database Password=;User ID="
%>


MODIFIED

<%

strdbname = session("dbname")
strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Server.MapPath("db\" & strdbname & ".accdb") & ";Jet OLEDB:Database Password=;User ID="
%>


now if I type the URL with the database name it connects perfect but i need to add the database name in the URL for every single page or i get an error
URL with DBname

www.mypage.com/login.asp?dbname=database2


error loading page

Microsoft Office Access Database Engine error '80004005'
Could not find file 'www.mypage.com/menu.asp/db/.accdb';.
/include/dbcommon.asp, line 49


but if i type " www.mypage.com/menu.asp?dbname=database2 " the page works perfect until refresh or change URL.
how can i create a stable SESSION that can be remember for ASP like the username?

admin 10/28/2015

Your logic needs to be adjusted. If session variable is populated - use database name from session variable. If session variable is not populated, read database name from the URL, save it to session variable and then proceed as usually.

G
gonzalosb author 10/28/2015

thank you admin for your guide and is there where i'm stock.

can you please oriented me with an example of how to collect and transfer the DBNAME from the URL to a SESSION variable and where to locate the code?

I assume that should be place on login page but not quite sure.
thank you for all your help.

G
gonzalosb author 10/28/2015

found it !!



if session("dbname")="" then

session("dbname")= request("dbname")

end if


thank you ADMIN !!!