Home > Software engineering >  In vb with ACCESS to login interface, but always appear in real time the wrong "- 2147217913&qu
In vb with ACCESS to login interface, but always appear in real time the wrong "- 2147217913&qu

Time:09-26

 Private Sub Command3_Click () 
Me. Adodc2. The ConnectionString="Provider=Microsoft. Jet. The OLEDB. 4.0; Data Source=G: \ MIS class set, vb design, teachers' archives. MDB. Persist Security Info=False "
Dim mn As Integer
Dim d As Integer
Dim e As Integer
Dim f As Integer
Dim strSQL As String
If the Me. The Option2. Value Then
If the Trim (Text1. Text) & lt;> "" And Trim (Text2. Text) & lt;> "" Then
Me.Adodc2.Com mandType=adCmdText
StrSQL="select * from teachers' account information where work number='" & amp; Text1. Text & amp; "'
"Me. Adodc2. RecordSource strSQL=
Me. Adodc2. Refresh
If Me. Adodc2. You. RecordCount & gt; 0 Then
If Me. Adodc2. You. Fields (" password ")=Text2. Text Then
D=MsgBox (" determine login ", 32 + 1, "the system asks")
If d=vbOK Then Unload the Me: Form2. Show
The Else
E=MsgBox (" password is not correct, whether or not to log in, you have a total of three chance!" VbOKCancel, password prompt box! "" )
If e=vbOK Then
Text2. SetFocus
Mn=mn + 1
If mn=3 Then
End
End the If
The Else
End
End the If
End the If
The Else
MsgBox "sorry, the user does not exist or job number is not correct!"
End the If
The Else
F=MsgBox (" I'm sorry, input work number or password cannot be empty!" VbOKCancel, input prompt box! "" )
If f=vbOK Then
Me. Text1. SetFocus
The Else
End
End the If
End the If
The Else
End the If
End Sub

CodePudding user response:

Your code, thickly dotted the If... Then END the IF see dizzy! With two goto also simple point!

CodePudding user response:

- 2147217913, this error is data overflow, you set the database field type and the actual data type does not match the cause,

CodePudding user response:

Do you want to match Text1. Text data, at the time of the input, for validation, I estimate is the relationship between Chinese Numbers. Make your Text types and database type is different.

CodePudding user response:

Is there a space between the job number=? Have deleted first

CodePudding user response:

type is different

CodePudding user response:

Dim mn As Integer 'this variable must be a variable module level
'the following your program optimization, and don't use Me., because the controls on the form,
 Private Sub Command3_Click () 
Adodc2. The ConnectionString="Provider=Microsoft. Jet. The OLEDB. 4.0; Data Source=G: \ MIS class set, vb design, teachers' archives. MDB. Persist Security Info=False "
Dim strSQL As String
If the Trim (Text1. Text)="" Or Trim (Text2. Text)=" "Then" the judgment should be on the front
MsgBox "sorry, input work number or password cannot be empty!" VbOKCancel, input prompt box! ""
The Exit Sub
End the If
If Option2. Value Then
Adodc2.Com mandType=adCmdText
StrSQL="select * from teachers' account information where work number='" & amp; Text1. Text & amp; "'" 'if a job number field is character, no problem this statement
Adodc2. RecordSource strSQL=
Adodc2. Refresh
If Adodc2. You. RecordCount & gt; 0 Then 'here to judge whether the recordset is empty
If Adodc2. You. Fields (" password ")=Text2. Text Then 'If the field is character password, this statement has no problem
Unload Me
Form2. Show
The Else
MsgBox "the password is not correct, whether or not to log in, you have a total of three chance!" VbOKCancel, password prompt box! ""
Text2. SetFocus
Mn=mn + 1
End the If
The Else
MsgBox "sorry, the user does not exist or job number is not correct!"
End the If
End the If
If mn=3 Then
End
End the If
End Sub


If working field is numeric types, then strSQL="select * from teachers' account information where work number=" & amp; Text1. Text & amp; "" 'note there is no single quotes
If the password field is numeric type, Then the If Adodc2. You. The Fields (" password ")=Val (Text2. Text) Then