回 帖 发 新 帖 刷新版面

主题:紧急求救各位大神!!!!VB编程时出现91错误对象变量或with未设置

Private Sub cmdOK_Click()
Dim txtSQL As String
Dim mrc As ADODB.Recordset

Dim MsgText As String
UserName = ""
If Trim(txtUserName.Text = "") Then
MsgBox "没有这个用户请重新输入用户名",vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
txtSQL = "select*from user_Info where user_ID=" ' & txtUserName.Text & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
  If mrc.EOF = True Then
MsgBox "没有这个用户请重新输入用户名¡", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
If Trim(mrc.Fields(1)) = Trim(txtPassword.Text) Then
OK = True
mrc.Close
Me.Hide
UserName = Trim(txtUserName.Text)
Else
MsgBox "密码不正确¡", vbOKOnly + vbExclamation, "警告"
txtPassword.SetFocus
txtPassword.Text = ""
End If
End If
End If
miCount = miCount + 1

End Sub
光标指出在If.mrc.EOF=True 错误,那位大神知道怎么改,十分感谢,可以的话大神留个QQ请教

回复列表 (共2个回复)

沙发

你有没有建立连接?connection

板凳


有这个程序Public fMainForm As frmMain
Public UserName As String


Sub Main()
    Dim fLogin As New frmLogin
    fLogin.Show vbModal
    If Not fLogin.OK Then
        'Login Failed so exit app
        End
    End If
    Unload fLogin


    Set fMainForm = New frmMain
    fMainForm.Show
End Sub
Public Function ConnectString() _
   As String
'returns a DB ConnectString
   ConnectString = "FileDSN=studentinfo.dsn;UID=sa;PWD="
End Function

我来回复

您尚未登录,请登录后再回复。点此登录或注册