对象'Refresh'的方法'IAdodc'失败
使用VB访问SQLSERVER出现错误提示貌似是adouser.refresh那里有问题PrivateSubcmdok_Click()'数据有效性检查Iftxtusern...
使用VB访问SQL SERVER 出现错误提示 貌似是adouser.refresh那里有问题
Private Sub cmdok_Click()
'数据有效性检查
If txtusername = "" Then
MsgBox "请输入用户名", , "登录"
txtusername.SetFocus
Exit Sub
End If
If txtpwd = "" Then
MsgBox "请输入密码", , "登录"
txtpwd.SetFocus
Exit Sub
End If
'判断用户名是否存在
adouser.RecordSource = "select * from users where username= " _
& Trim(txtusername) & " "
adouser.Refresh
If adouser.Recordset.EOF = True Then
MsgBox "用户名不存在", , "登录"
trytimes = trytimes + 1
If trytimes >= 3 Then
MsgBox "已经三次尝试未成功,本系统将关闭", , "登录"
End
Else
Exit Sub
End If
End If
'判断密码是否正确
If Trim(adouser.Recordset.Fields("password")) <> Trim(txtpwd) Then
MsgBox "密码错误", , "登录"
tyrtimes = trytimes + 1
txtpwd.SelStart = 0
txtpwd.SelLength = Len(txtpwd)
txtpwd.SetFocus
If trytimes >= 3 Then
MsgBox "已经三次尝试未成功,本系统将关闭", , "登录"
End
Else
Exit Sub
End If
Else
strusername = Trim(txtusername)
Unload Me
End If
已经加上单引号了 还是提示错误 展开
Private Sub cmdok_Click()
'数据有效性检查
If txtusername = "" Then
MsgBox "请输入用户名", , "登录"
txtusername.SetFocus
Exit Sub
End If
If txtpwd = "" Then
MsgBox "请输入密码", , "登录"
txtpwd.SetFocus
Exit Sub
End If
'判断用户名是否存在
adouser.RecordSource = "select * from users where username= " _
& Trim(txtusername) & " "
adouser.Refresh
If adouser.Recordset.EOF = True Then
MsgBox "用户名不存在", , "登录"
trytimes = trytimes + 1
If trytimes >= 3 Then
MsgBox "已经三次尝试未成功,本系统将关闭", , "登录"
End
Else
Exit Sub
End If
End If
'判断密码是否正确
If Trim(adouser.Recordset.Fields("password")) <> Trim(txtpwd) Then
MsgBox "密码错误", , "登录"
tyrtimes = trytimes + 1
txtpwd.SelStart = 0
txtpwd.SelLength = Len(txtpwd)
txtpwd.SetFocus
If trytimes >= 3 Then
MsgBox "已经三次尝试未成功,本系统将关闭", , "登录"
End
Else
Exit Sub
End If
Else
strusername = Trim(txtusername)
Unload Me
End If
已经加上单引号了 还是提示错误 展开
3个回答
展开全部
adouser.RecordSource = "select * from users where username= " _
& Trim(txtusername) & " "
->
adouser.RecordSource = "select * from users where username= '" _
& Trim(txtusername) & "'"
用户名两边加单引号
检查adouser对象关联的Connection对象,或adouser对象的ConnectionString设置,确保能够成功连接数据库 ,然后再检查SQL问题
& Trim(txtusername) & " "
->
adouser.RecordSource = "select * from users where username= '" _
& Trim(txtusername) & "'"
用户名两边加单引号
检查adouser对象关联的Connection对象,或adouser对象的ConnectionString设置,确保能够成功连接数据库 ,然后再检查SQL问题
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
If adouser.Recordset.EOF = True Then
改用
If adouser.Recordset.BOF or adouser.Recordset.EOF Then
试试
改用
If adouser.Recordset.BOF or adouser.Recordset.EOF Then
试试
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询