Click here to Skip to main content
15,921,467 members
Please Sign up or sign in to vote.
1.00/5 (1 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

VB
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
        .AddNew
        !Username = Username
        !LoginTime = LoginTime
        .Update
   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
   lstLog.ListItems.Clear
   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) = ""
             Else
                lstItem.SubItems(3) = Rs(3).Value
             End If
            lstItem.SubItems(4) = Rs(4).Value
            Rs.MoveNext
            Loop
End Sub
Posted
Updated 21-Apr-13 5:07am
v2

1 solution

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[^].

Regards,

— Manfred
 
Share this answer
 
v2
Comments
Aleu Philip 21-Apr-13 11:49am    
actually code works well with access database..
Manfred Rudolf 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900