为了账号安全,请及时绑定邮箱和手机立即绑定

我是能看到初始进入的页面,但是输入账号密码就会出现那个提示了。为什么?

我是能看到初始进入的页面,但是输入账号密码就会出现那个提示了。为什么?

RISEBY 2022-07-22 17:09:45
Private Sub cmdOk_Click()UserName = "sa"If Trim(txtUserName.Text = "") ThenMsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"txtUserName.SetFocusElsesql = "select * from userpwd where U_name = " & "'" & txtUserName.Text & "'"Set rs = ExecuteSQL(sql, msgtxt)If rs.EOF = True Then (这里出了问题)MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"txtUserName.SetFocusElseIf Trim(rs.Fields(1)) = Trim(txtPassword.Text) ThenOK = TrueUserName = Trim(txtUserName.Text)UserPass = Trim(txtPassword.Text)rs.CloseMe.HideElseMsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"txtPassword.SetFocustxtPassword.Text = ""End IfEnd IfEnd IfExecuteSQL函数Public Function ExecuteSQL(ByVal sql _As String, MsgString As String) _As ADODB.Recordset'executes SQL and returns RecordsetDim cnn As ADODB.ConnectionDim rst As ADODB.RecordsetDim sTokens() As StringOn Error GoTo ExecuteSQL_ErrorsTokens = Split(sql)Set cnn = New ADODB.Connectioncnn.Open ConnectStringIf InStr("INSERT,DELETE,UPDATE,EXECUTE", _UCase$(sTokens(0))) Thencnn.Execute (sql)MsgString = sTokens(0) & _" query successful"ElseSet rst = New ADODB.Recordsetrst.Open Trim$(sql), cnn, _adOpenKeyset, _adLockOptimistic'rst.MoveLast 'get RecordCountSet ExecuteSQL = rstMsgString = "查询到" & rst.RecordCount & _" 条记录 "End IfExecuteSQL_Exit:Set rst = NothingSet cnn = NothingExit FunctionExecuteSQL_Error:MsgString = "查询错误: " & _Err.DescriptionResume ExecuteSQL_ExitEnd Function我也不会调试。据说是VB If mrc.EOF = True Then 实时错误 91 据说ExecuteSQL函数出问题,可以帮我改下么。谢谢你,很急~
查看完整描述

2 回答

?
慕桂英4014372

TA贡献1871条经验 获得超13个赞

将出问题的地方按下面修改:
If rs.RecordCount = 0 Then
MsgBox "没有这个用户,请重新输入用户名
rs.EOF是记录集的结束标记

查看完整回答
反对 回复 2022-07-24
?
忽然笑

TA贡献1806条经验 获得超5个赞

Dim w_s As String, w_d As String, sp() As String
Function cc()
Dim i As Integer
w_s = "a,b,c,d,e,f,g,h"
sp = Split(w_s, ",", -1)
For i = LBound(sp) To UBound(sp)
MsgBox sp(i)
Next
End Function

Private Sub Command1_Click()
Call cc
End Sub


查看完整回答
反对 回复 2022-07-24
  • 2 回答
  • 0 关注
  • 109 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信