This topic is locked

Users Database / Which Database

9/28/2004 12:02:48 PM
ASPRunnerPro General questions
author

Hello,
A while ago, I originally started this thread(671). I responded to know if I could not only add the username and time that the use logged in, but add the database that they accessed. You replied with that you needed more info for this.
I have four databases - case, green, hillman, and ocqueoc
That is the name of the databases and the directory they are in.
Also, I have a field in my Users database (tables are Users and logins) fields in the logins tables are username, loggedin, and database.
I don't need anything specific, but just able to differentiate between case, green, etc. So if I can just put a filename such as (case_list.asp) in that field, that would be fine.
Each seperate database is launched from a seperate database link. So the link for case, directs them to //asp/case/case_login.asp
Within the case_login.asp it refers to the //asp/users/db/users.mdb file for user information where logins are recorded, new users are entered and validated.
After thinking about this....I figured the current code may help.

Below is the current codeing that I am using to put the username and logged in time for the user. It works Great!!!! Thanks for that advice.
Further, I would think the first part would be simple to modify....just add "database" to the (username, loggedin, database)
It's the second part that gets me....I see the session UserID, and the Now for the time....but I would need to add on the end some file name (like I was suggesting in my previous post). HELP! Thanks.
strSQL = "insert into logins (Username, LoggedIn) values ('" & Session("UserID") & "', Now())"

dbConnection.Execute strSQL

Sergey Kornilov admin 9/30/2004

Allan,
after user logs in you can use something like this to extract current database name from connection string and store it in Session variable for later use:

ind = InStr(strConnection, "DBQ=")

if ind>0 then

    strDB = Mid(strConnection, ind+4)

ind = InStr(strDB, ";")

if ind>0 then

      strDB = Left(strDB, ind-1)

  Session("Database") = strDB

end if
end if


After that you can use this variable to insert database name into your table.