Click here to Skip to main content
13,147,591 members (30,278 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Am testing out the funtionality of a userlog table i've created in sql server 2005 database. The userlog table has 5 columns logid(int), username(varchar), logintime(varchar), logouttime(varchar), and date(varchar). logid,username, & logintime insert successfully but i get the above error when i click logout from my vb application. The 17 appears in my error because my system time at logout was actually 17:57:33, the current value of LogOutTime is 17:57:33

Function UserLoginTime(Username As String, LoginTime As Date) As Integer
If Rs.State = adStateOpen Then Rs.Close
    sql = " Select * From Userlog"
   Rs.Open sql, RSconn
    With Rs
        !Username = Username
        !LoginTime = LoginTime
   End With
   UserLoginTime = Rs(0).Value
End Function
Function UserLogoutTime(Index As Integer, LogOutTime As String) As Integer
If Rs.State = adStateOpen Then Rs.Close
    sql = " Update Userlog set Userlog.LogoutTime=#" & LogOutTime & "# Where (userlog.logid)= " & Index & ""
Rs.Open sql, RSconn
End Function
Sub DisplayUserLog(lstLog As ListView, mDate As Date)
Dim lstItem As ListItem, a As Integer
If Rs.State = adStateOpen Then Rs.Close
   sql = " Select * From Userlog Where (Userlog.Date)=#" & mDate & "#"
   Rs.Open sql, RSconn
   Do While Not Rs.EOF
    a = a + 1
        Set lstItem = lstLog.ListItems.Add(, , a)
            lstItem.SubItems(1) = Rs(1).Value
            lstItem.SubItems(2) = Rs(2).Value
             If IsNull(Rs(3).Value) Then
                lstItem.SubItems(3) = ""
                lstItem.SubItems(3) = Rs(3).Value
             End If
            lstItem.SubItems(4) = Rs(4).Value
End Sub
Posted 21-Apr-13 5:02am
Updated 21-Apr-13 5:07am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I see you are using a date/time literal format that used to be en vogue last time I did something with MS Abscess Access[^]. MS SQL Server uses different date/time literals[^].


— Manfred
Aleu Philip 21-Apr-13 11:49am
actually code works well with access database..
Manfred R. Bihy 21-Apr-13 11:55am
Hello? Your post says you're using MS SQL Server 2005. Now re-read my post: MS SQL Server date time literals are different from not the same as MS Access date/time literals.
Was that easier to understand now?
Did you follow the links I added (all of them please there are only two of them)?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170915.1 | Last Updated 21 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100