“运行时错误'13'。类型不匹配“ [英] "run-time error '13'. Type mismatch"
问题描述
我有一个功能UserLoginTime如下。用户名字段的结构,用户名字段的数据类型varchar(50)和Logintime字段的数据类型日期时间。问题是以下代码行在运行时给出了一个错误运行时错误''13''。类型不匹配,问题所在的任何帮助。在vb中我不是很精明。
功能 UserLoginTime(用户名< span class =code-keyword> As String ,LoginTime As 日期)作为 整数
如果 Rs.State = adStateOpen 然后 Rs.Close
sql = 选择*来自用户日志
Rs.Open sql,RSconn
带 Rs
.AddNew
!用户名=用户名
!LoginTime = LoginTime
.Update
结束 使用
UserLoginTime = Rs( 0 )。值
你c不要插入Recordset,直到你添加新的记录!!!
请参阅: http://msdn.microsoft.com/en-us/library/windows/desktop/ms680885%28v=vs.85 %29.aspx [ ^ ]
rstEmployees.AddNew
rstEmployees!firstname = strFirstName
rstEmployees!LastName = strLastName
rstEmployees.Update
但请记住,你需要 open Recordset [ ^ ] adLockOptimistic LockType [<小时ef =http://msdn.microsoft.com/en-us/library/windows/desktop/ms680855%28v=vs.85%29.aspxtarget =_ blanktitle =New Window> ^ 一>]。
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
.AddNew
!Username = Username
!LoginTime = LoginTime
.Update
End With
UserLoginTime = Rs(0).Value
You can''t insert into Recordset until, you add new record!!!
See this: http://msdn.microsoft.com/en-us/library/windows/desktop/ms680885%28v=vs.85%29.aspx[^]
rstEmployees.AddNew rstEmployees!firstname = strFirstName rstEmployees!LastName = strLastName rstEmployees.Update
But remember, you need to open Recordset[^] with adLockOptimistic LockType[^].
这篇关于“运行时错误'13'。类型不匹配“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!