Home > Software engineering >  If MRC. EOF=True then 91 error, object variables or with variable is undefined
If MRC. EOF=True then 91 error, object variables or with variable is undefined

Time:09-20



 Public OK As Boolean 




Private Sub cmdCancel_Click ()
OK=False
Me. Hide
End Sub


Private Sub cmdOK_Click ()
Dim MRC As ADODB. You
Dim STRMSG As String
TxtSQL="select the uid from the userinfo where uid='" & amp; Trim (txtUserName. Text) & amp; "'
"The Set MRC=the ExecuteSQL (txtSQL, STRMSG)
If MRC. EOF=True Then
MsgBox "user name wrong!" , vbExclamation + vbOKOnly, "warning"
TxtUserName. SetFocus
TxtUserName. SelStart=0
TxtUserName. SelLength=Len (txtUserName. Text)
The Exit Sub
End the If
The UserName=MRC. Fields (0)
TxtSQL="select the UID from the userinfo where the PWD='" & amp; Trim (txtPassword. Text) & amp; "'
"The Set MRC=the ExecuteSQL (txtSQL, STRMSG)
If MRC. EOF=True Then
MsgBox "wrong password!" , vbExclamation + vbOKOnly, "warning"
TxtPassword. SetFocus
TxtPassword. SelStart=0
TxtPassword. SelLength=Len (txtPassword. Text)
The Exit Sub
End the If
OK=True
Frmmain. Show
Unload Me
End Sub



CodePudding user response:

Your the ExecuteSQL () returns Nothing,
Judgment to
 If MRC Is Nothing Then 

CodePudding user response:

Thank you for your good friend his busy schedule to solve! There is no error in this process is actually the VB ADO database programming
 Private Sub cmdOK_Click () 
Dim MRC As ADODB. You
Dim STRMSG As String
Dim cn As ADODB. Connection
Set the cn=New ADODB. Connection
Cn. Open "the PROVIDER=MSDASQL; SQL SERVER DRIVER={};" & "SERVER=JOGGE - PC; The DATABASE=PersonMIS; UID=sa; The PWD=123456 "

. Is just before dawn.

CodePudding user response:

Delete records
 'Public Sub RecordDelete () 
Dim sSql As String
Dim intCount As Integer

'On Error GoTo myErr

If msgList. Rows & gt; 1 Then
If MsgBox (" really want to delete this file record?" , vbOKCancel + vbExclamation, "warning")=vbOK Then
IntCount=msgList. Row
SSql="delete from & amp; MsTableName & amp; Where kqid='" & amp; Trim (msgList. TextMatrix (msgList. Row, 1)) & amp; "' and kqdate=cdate ('" & amp; Format (msgList. TextMatrix (msgList. Row, 3), "yyyy - mm - dd) & amp; "')
"
'dbHuaxia. Execute sSql, dbSQLPassThrough
ShowData
If msgList. Rows & gt; 1 Then
If intCount=msgList. Rows Then
'MovCursor msgList. Rows 1, msgList
The Else
'MovCursor intCount, msgList
End the If
End the If
End the If
End the If

The Exit Sub

'myErr:
'ShowError
End Sub

Consult movcursor error


CodePudding user response:

All commented On the Error Resume Next statement, in VB6 IDE,
The error and then click the debugging, the cursor will stop error in the statement,
Or
In doubt may have a logical error statements in advance to set breakpoints, run through the breakpoint interrupt,

At this point can be used in the immediate window
? The variable name
Or
? The function name () function parameter
Or
Process (parameters)
Auxiliary debugging,
  • Related