Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB6
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
        .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 21-Apr-13 6:02am
Edited 21-Apr-13 6:07am
v2

1 solution

Rate this: bad
good
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[^].
 
Regards,
 
— Manfred
  Permalink  
v2
Comments
Aleu Philip at 21-Apr-13 11:49am
   
actually code works well with access database..
Manfred R. Bihy at 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
0 BillWoodruff 260
1 Mathew Soji 244
2 Afzaal Ahmad Zeeshan 232
3 OriginalGriff 231
4 Maciej Los 230
0 OriginalGriff 6,369
1 Sergey Alexandrovich Kryukov 5,973
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,045


Advertise | Privacy | Mobile
Web02 | 2.8.1411019.1 | Last Updated 21 Apr 2013
Copyright © CodeProject, 1999-2014
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