一新人 纠结我好久的问题 那位帮帮忙
提示错误3704 对象关闭时不允许操作这到底是那错了
Public username As String
Public userpower As String
Public myconnection As New ADODB.Connection
Dim txtsql As String
Public n As Integer
Private Sub Command1_Click()
Dim txtsql As String
Dim Msgtext As String
Dim rsd1 As ADODB.Recordset
Dim rsd2 As ADODB.Recordset
username = ""
If Trim(txtid.Text = "") Then
MsgBox "用户名不能为空,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtid.SetFocus
Else
txtsql = "select * from 用户表 where 用户名=" '&txtid.text&'""
Set rsd1 = myconnection.Execute(txtsql)
If rsd1.EOF Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtid.Text = ""
txtpwd.Text = ""
txtid.SetFocus
Else
username = Trim(txtid.Text)
txtsql = "select 口令,权限 from 用户表 where 用户名=" '&username&'""
Set rsd2 = myconnection.Execute(txtsql)
If Trim(rsd2.Fields(0)) = Trim(txtpwd.Text) Then
userpower = rsd2.Fields(1)
rsd2.Close
Unload Me
主窗体.Show
myconnection.Close
Else
MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtpwd.Text = ""
txtpwd.SetFocus
End If
End If
End If
n = n + 1
If n > 3 Then
MsgBox "操作次数过了三次"
Unload Me
myconnection.Close
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
myconnection.ConnectionString = "driver={sql server};server=chh;uid=sa;pwd=111;database=学生信息管理"
myconnection.Open
n = 0
End Sub