Database 运行时错误3464数据类型错误
每当我输入此代码时,都会给出: 数据不匹配错误为3464 我试着练习你的视频“从Access创建登录第1部分” 代码如下:Database 运行时错误3464数据类型错误,database,vb.net,ms-access,Database,Vb.net,Ms Access,每当我输入此代码时,都会给出: 数据不匹配错误为3464 我试着练习你的视频“从Access创建登录第1部分” 代码如下: Private Sub Command1_Click() If IsNull(Me.txtLoginId) Then MsgBox "Please enter LoginID", vbInformation, "LoginID Required" Me.txtLoginId.SetFocus ElseIf IsNull(Me.txtPass
Private Sub Command1_Click()
If IsNull(Me.txtLoginId) Then
MsgBox "Please enter LoginID", vbInformation, "LoginID Required"
Me.txtLoginId.SetFocus
ElseIf IsNull(Me.txtPassword) Then
MsgBox "Please enter password", vbInformation, "Password Required"
Me.txtPassword.SetFocus
Else
'process the job
If (IsNull(DLookup("UserLogin", "tblUser", "UserLogin ='" & Me.txtLoginId.Value & "'"))) Or _
(IsNull(DLookup("password", "tblUser", "Password ='" & Me.txtPassword.Value & "'"))) Then
MsgBox "Incorrect LoginId or Password"
Else
MsgBox "LoginID and Password correct"
End If
End If
End Sub
那个代码是错误的,我知道你们从视频中复制了它,但它做得不对,我认为作者后来修改了。例如,这不是测试用户id是否与密码匹配,而是测试用户id或密码是否与任何值匹配。因此,您可能有多个具有相同密码的用户,并且它将通过验证。当您得到数据类型不匹配时,这将表明您的表设置不正确,查看此处的引号,userid和password都应该是文本。它们是吗 你想要的是这样的东西; 如果(IsNull(DLookup(“[UserLogin]”、“tblUser”、“[UserLogin]=”、“&Me.txtLoginID.Value&“’和password=”、&Me.txtPassword.Value&“”),则 但是我不会用DLookup,而是用eLookup。。更快、更灵活