![]() |
#2
bnegsh2012-05-04 13:30
|

Private Sub Command1_Click()
If Trim(Text1.Text) <> "" And Trim(Text2.Text) <> "" Then
Adodc1.RecordSource = "select * from 用户表 where username='" + Trim(Text1.Text) + "' and passwrod='" + Trim(Text2.Text) + "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount = 1 Then
Adodc1.Recordset.Close
frm2.Show
Me.Hide
Else
MsgBox "错误的账号或密码!", vbInformation + vbOKOnly, "错误信息"
Text2.Text = ""
Text1.SetFocus
End If
ElseIf Text1.Text = "" Then
MsgBox "账号不能为空!", vbInformation + vbOKOnly, "错误信息"
Text1.SetFocus
Else
MsgBox "密码不能为空!", vbInformation + vbOKOnly, "错误信息"
Text2.SetFocus
End If
End Sub
红色为出错部分,显示ADODC1 FORM子句语法错误
If Trim(Text1.Text) <> "" And Trim(Text2.Text) <> "" Then
Adodc1.RecordSource = "select * from 用户表 where username='" + Trim(Text1.Text) + "' and passwrod='" + Trim(Text2.Text) + "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount = 1 Then
Adodc1.Recordset.Close
frm2.Show
Me.Hide
Else
MsgBox "错误的账号或密码!", vbInformation + vbOKOnly, "错误信息"
Text2.Text = ""
Text1.SetFocus
End If
ElseIf Text1.Text = "" Then
MsgBox "账号不能为空!", vbInformation + vbOKOnly, "错误信息"
Text1.SetFocus
Else
MsgBox "密码不能为空!", vbInformation + vbOKOnly, "错误信息"
Text2.SetFocus
End If
End Sub
红色为出错部分,显示ADODC1 FORM子句语法错误