能不能再看看这段代码 哪里出错了
Option Explicit
Public conn As ADODB.Connection
Sub main()
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;" _
+ "User ID=sa;password=123456;Initial Catalog=VB;Data Source=127.0.0.1"
conn.Open
丽都影视.Show
End Sub
Private Sub cmdOK_Click()
Dim Try_times
If txtUserName.Text = "" Then
MsgBox "用户名不能为空!", vbOKOnly + vbInformation, "友情提示"
txtUserName.SetFocus
Exit Sub
End If
If txtPassword.Text = "" Then
MsgBox "密码不能为空!", vbOKOnly + vbInformation, "友情提示"
txtPassword.SetFocus
Exit Sub
End If
Dim strSQl As String
strSQl = "select * from Users where 用户名='" & Trim$(txtUserName.Text) & "' and 密码='" & Trim$(txtPassword.Text) & "' "
Dim str As New ADODB.Recordset
Set str = New ADODB.Recordset
str.CursorLocation = adUseClient
str.Open strSQl, conn, adOpenStatic, adLockReadOnly
With str
If .State = adStateOpen Then .Close
.Open strSQl
If .EOF Then
Try_times = Try_times + 1
If Try_times >= 3 Then
MsgBox "您已经三次尝试进入本系统,均不成功,系统将自动关闭", vbOKOnly + vbCritical, "警告"
Unload Me
Else
MsgBox "对不起,用户名不存在或密码错误 !", vbOKOnly + vbQuestion, "警告"
txtUserName.SetFocus
txtUserName.Text = ""
txtPassword.Text = ""
End If
Else
Unload Me
影视俱乐部.Show
End If
End With
End Sub