Click here to Skip to main content
11,705,052 members (52,742 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: VB6
Ii've got a funtion UserLoginTime as below. The structure of my userlog table datatype varchar(50) for Username field and datatype datetime for Logintime field. Problem is the following line of code gives me an error at runtime "run-time error '13'. Type mismatch, " Any help where the problem could be. Am not very savvy in 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
        !Username = Username
        !LoginTime = LoginTime
   End With
   UserLoginTime = Rs(0).Value
Posted 12-Apr-13 7:09am
Edited 12-Apr-13 7:13am
CHill60 at 12-Apr-13 13:13pm
When you step through the code with the debugger which line is it precisely that is giving you the error?
Aleu Philip at 12-Apr-13 13:15pm
line 11 userLogintime = Rs(0).Value gives the error
CHill60 at 12-Apr-13 13:20pm
Ok .. you've used Select * From Userlog. Try explicitly naming the columns you want returned instead of using "*" - obviously with the LoginTime as the first column :-)
Aleu Philip at 12-Apr-13 13:26pm
worked like a baby! thanks man.
Sergey Alexandrovich Kryukov at 12-Apr-13 13:30pm
I hope you understand why did I delete your "answer" which you even accepted formally. Why?
Aleu Philip at 12-Apr-13 13:32pm
I dont..would be pleased to

well i not the author..thanks man.
Sergey Alexandrovich Kryukov at 12-Apr-13 15:34pm
Sorry for possible miscommunication…
ThePhantomUpvoter at 12-Apr-13 13:28pm
You are trying to return a datetime from your function as an integer.

1 solution

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

Solution 2

You can't insert into Recordset until, you add new record!!!

See this:[^]
rstEmployees!firstname = strFirstName
rstEmployees!LastName = strLastName

But remember, you need to open Recordset[^] with adLockOptimistic LockType[^].

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 609
1 OriginalGriff 439
2 Andy Lanng 215
3 CPallini 202
4 F-ES Sitecore 160
0 OriginalGriff 8,958
1 Sergey Alexandrovich Kryukov 8,276
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,606

Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 12 Apr 2013
Copyright © CodeProject, 1999-2015
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