473,703 Members | 5,003 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CHECK IF USER ALREADY LOGGED IN

Hi all,

below is an insert statement on an asp page that stores the date and time
that a driver logged on, what I need is to check that they are now already
logged on fields are

SQL Server 2000

ID int
DRIVER_NO int
ON_DATE datetime
OFF_DATE datetime
ON_NOW nvarchar
SESSION_ID int

The ON_NOW column reads on or off depending whether the driver logged out or
not, if they havent we need to close the previous logon session and mark it
with 'off' and enter a date time into OFF_DATE column.

sql = "INSERT INTO logon (DRIVER_NO, ON_NOW, SESSION_ID" & _
") VALUES (" & _
"'" & username & "', 'on', '" & Session.Session ID & "')"
racking my brains with this one for days any help would be appreciated.

--
Simon Gare
The Gare Group Limited

website: www.thegaregroup.co.uk
website: www.privatehiresolutions.co.uk
Apr 13 '07 #1
4 10192
Simon Gare wrote:
Hi all,

below is an insert statement on an asp page that stores the date and
time that a driver logged on, what I need is to check that they are
now already logged on fields are

SQL Server 2000

ID int
DRIVER_NO int
ON_DATE datetime
OFF_DATE datetime
ON_NOW nvarchar
SESSION_ID int

The ON_NOW column reads on or off depending whether the driver logged
out or not, if they havent we need to close the previous logon
session and mark it with 'off' and enter a date time into OFF_DATE
column.

sql = "INSERT INTO logon (DRIVER_NO, ON_NOW, SESSION_ID" & _
") VALUES (" & _
"'" & username & "', 'on', '" & Session.Session ID & "')"
racking my brains with this one for days any help would be
appreciated.
I don't understand what the problem is. You have a vbscript statement that
appears as if it will generate a valid sql insert statement (I assume you've
written it to Response and verified that the statement being generated is
valid and runs in QA). What do you need help with?

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Apr 13 '07 #2
Hi Bob,

the insert statement works, but if the driver is already logged in I need
some way of closing the last session stored in the table, some kind of IF
statement attached to the below. As per the table below the data would read

574 16 13/04/2007 13:03:52 <NULL on 938471687

If the driver doesn't log off, when he logs on again it would create another
entry

575 16 13/04/2007 13:15:03 <NULL on 938471958

I need a way of checking if driver username status from previous logon =
'on' if so then update row i.e.

574 16 13/04/2007 13:03:52 13/04/2007 13:15:02 off 938471687

then create new entry.

Hope that explains it better.

Regards
Simon

"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcomwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
Simon Gare wrote:
Hi all,

below is an insert statement on an asp page that stores the date and
time that a driver logged on, what I need is to check that they are
now already logged on fields are

SQL Server 2000

ID int
DRIVER_NO int
ON_DATE datetime
OFF_DATE datetime
ON_NOW nvarchar
SESSION_ID int

The ON_NOW column reads on or off depending whether the driver logged
out or not, if they havent we need to close the previous logon
session and mark it with 'off' and enter a date time into OFF_DATE
column.

sql = "INSERT INTO logon (DRIVER_NO, ON_NOW, SESSION_ID" & _
") VALUES (" & _
"'" & username & "', 'on', '" & Session.Session ID & "')"
racking my brains with this one for days any help would be
appreciated.

I don't understand what the problem is. You have a vbscript statement
that
appears as if it will generate a valid sql insert statement (I assume
you've
written it to Response and verified that the statement being generated is
valid and runs in QA). What do you need help with?

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Apr 13 '07 #3
So create a stored procedure that accepts the username and session id.

CREATE PROCEDURE LogDriverOn (
@driver int,
@session int) AS
DECLARE @now datetime
SET @now=GETDATE()
UPDATE logon
SET ON_NOW='off',
OFF_DATE = @now
WHERE DRIVER_NO = @user AND
ON_NOW = 'on'
INSERT INTO logon (DRIVER_NO, ON_NOW, SESSION_ID)
VALUES (@user,'on',@no w,@session)

Then in ASP, simply call it like this:

conn.LogDriverO n username, Session.Session ID

Bob Barrows

Simon Gare wrote:
Hi Bob,

the insert statement works, but if the driver is already logged in I
need some way of closing the last session stored in the table, some
kind of IF statement attached to the below. As per the table below
the data would read

574 16 13/04/2007 13:03:52 <NULL on 938471687

If the driver doesn't log off, when he logs on again it would create
another entry

575 16 13/04/2007 13:15:03 <NULL on 938471958

I need a way of checking if driver username status from previous
logon = 'on' if so then update row i.e.

574 16 13/04/2007 13:03:52 13/04/2007 13:15:02 off
938471687

then create new entry.

Hope that explains it better.

Regards
Simon

"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcomwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
>Simon Gare wrote:
>>Hi all,

below is an insert statement on an asp page that stores the date and
time that a driver logged on, what I need is to check that they are
now already logged on fields are

SQL Server 2000

ID int
DRIVER_NO int
ON_DATE datetime
OFF_DATE datetime
ON_NOW nvarchar
SESSION_ID int

The ON_NOW column reads on or off depending whether the driver
logged out or not, if they havent we need to close the previous
logon session and mark it with 'off' and enter a date time into
OFF_DATE column.

sql = "INSERT INTO logon (DRIVER_NO, ON_NOW, SESSION_ID" & _
") VALUES (" & _
"'" & username & "', 'on', '" & Session.Session ID & "')"
racking my brains with this one for days any help would be
appreciated .

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Apr 13 '07 #4
Oh, geez, I lost track of my variables. See edits inline:
Bob Barrows [MVP] wrote:
So create a stored procedure that accepts the username and session id.

CREATE PROCEDURE LogDriverOn (
@driver int,
@session int) AS
DECLARE @now datetime
SET @now=GETDATE()
UPDATE logon
SET ON_NOW='off',
OFF_DATE = @now
WHERE DRIVER_NO = @user AND
WHERE DRIVER_NO = @driver AND
ON_NOW = 'on'
INSERT INTO logon (DRIVER_NO, ON_NOW, SESSION_ID)
VALUES (@user,'on',@no w,@session)
VALUES (@driver ,'on',@now,@ses sion)
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Apr 13 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
17276
by: fr? | last post by:
Hi, i have a website , on wich users have to log in credentials are checked against mysql db some session vars are set during login for use somewhere else in the code. Is there a way to prohibit a user to log in twice. A was thinking about setting some flag in the db, but in that case i need some timeout in case a pc can crash for instance so the user does
1
8749
by: jach | last post by:
How can I get the domain, username and PC network name (Win 2000 Pro & Win XP Pro PC's) of the current logged on user (logged onto a domain and access an intranet page, Window 2000 server running IIS) and put this automatically in a textbox in an webpage. Can this be done with asp & VB? I basically want to automatically populate a username field with the users logon so the do not need to type it themselves, leading to type errors. ...
19
32315
by: wetherbean | last post by:
Hi group..I am writing a playlist management protocol where I have a file that holds all the playlists and a file that holds all the songs....before a playlist is created I need to check to see if the playlist file is empty so that I can assign an integer value to a playlist id field if it is the first playlist being written to the file....can anyone help?? Thanks in advance wetherbean
4
1443
by: shapper | last post by:
Hello, I am creating a Poll system and I need to check if a user has already voted. What should be the best way to do this? 1. Should I save the user IP along with its vote in the database? But does not some users IP change each time they access the internet?
1
2583
by: =?ISO-8859-1?Q?Andr=E9?= Wyrwa | last post by:
Hei, I know this kind of stuff has probably been asked a couple of times already, and did quite a bit of googling about it, but the answers i found were either unsatisfying or not specific enough to what i want to do: I'm writing on a (Linux only) python daemon that runs as regular user. Under certain conditions the daemon should create a total screen lock as
1
2410
by: SmartPHP | last post by:
Hi friends, My problem is...i want to open an application on click of some link...but before opening that application i want to check if that application is already opened with some other login id or not....if it is already opened with some other id i want to show a warning message... for example...suppose i want to open yahoo on click of some link...and suppose yahoo is having the restriction that at a time only one user can login from...
15
2700
by: paul814 | last post by:
Is it possible to display the logged in user that is accessing the form, in a textbox? so say I have txtname I want to display the username of the person that is logged in to the PC in that box, can I do this? How would this be done?
2
2293
by: ascll | last post by:
Greetings, How to I know existing user already login to my website (using ASP.net 2.0, MS Web Developer's login wizard)? If the user already login, I would like to set the path for Hyperlink A to
1
3446
by: steevan16 | last post by:
Hi, Not sure if I am in the right section. Just have a query about manipulating excel spreadsheet using vbscript. I am developing a vbscript which runs on client xp machines to retrieve certain user environment variables and to write the same as a record on an excel spreadsheet placed on a network share where the user has got write access to. However, due to the massive number of users in the domain it is expected that the same excel...
0
8676
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9020
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8972
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7878
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6602
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5926
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4435
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2467
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2073
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.