哪位大虾帮忙看看,这是我写的登陆,怎么会出错呢?
Dim i As New ADODB.Connection
Dim j As New ADODB.Recordset
Private Sub Command1_Click()
Dim num As Integer
Dim sql As String
Set i = New ADODB.Connection
Set j = New ADODB.Recordset
i.ConnectionString = "provider=sqloledb.1;data source=(local);user id=sa;pwd=247162545;initial catalog=sdb"
i.Open
sql = "select * from s where sno='" & Trim(Text1.Text) & "'"
j.Open sql, i, adOpenStatic, adLockOptimistic
If j.RecordCount > 0 Then
If j.Fields("sn") = Text2 Then
MsgBox "登陆成功"
Else
If num > 3 Then
MsgBox "超出登陆次数"
Unload Me
End If
MsgBox "密码不对"
Text2.Text = ""
Text2.SetFocus
Exit Sub
End If
Else
MsgBox "用户名不正确"
Text1.Text = ""
Text1.SetFocus
Exit Sub
End If
End Sub