求助VB编程高手,实时错误3704 对象关闭时 不允许操作 10
程序代码如下:DimMydbAsNewADODB.RecordsetDimMydb1AsNewADODB.RecordsetDimStr_textAsStringPriv...
程序代码如下:
Dim Mydb As New ADODB.Recordset
Dim Mydb1 As New ADODB.Recordset
Dim Str_text As String
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label4.ForeColor = QBColor(11)
Label5.ForeColor = QBColor(11)
End Sub
Private Sub Label4_Click()
Dim Str_name As String
Dim Str_password As String
Dim Str_username As String
Dim Str_userpassword As String
Dim Remainday As Long
Str_name = txt_name.Text
Str_password = txt_password.Text
Set Mydb = ExeCutesql("select user from user1 where user='" & Str_name & "'", Str_text)
If Mydb.EOF Then
MsgBox "你输入的用户名不存在,请重新输入!", vbOKOnly + 32, "注意"
txt_name = ""
txt_password = ""
txt_name.SetFocus
Else
Set Mydb1 = ExeCutesql("select user,pass from user1 where user='" & Str_name & "'", Str_text)
Str_username = Trim(Mydb1.Fields(0))
Str_userpassword = Trim(Mydb1.Fields(1))
If Trim(Str_password) = Str_userpassword Then
frm_main.Show
Mydb.Close
Mydb1.Close
Set Mydb = Nothing
Set Mydb1 = Nothing
Unload Me
Else
MsgBox "你输入的密码错误,请重新输入!", vbOKOnly + 32, "注意"
txt_password.SetFocus
End If
End If
End Sub
运行时出现错误:错误3704,对象关闭时不允许操作!
错误代码:If Mydb.EOF Then
求教各位高手大侠!!! 展开
Dim Mydb As New ADODB.Recordset
Dim Mydb1 As New ADODB.Recordset
Dim Str_text As String
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label4.ForeColor = QBColor(11)
Label5.ForeColor = QBColor(11)
End Sub
Private Sub Label4_Click()
Dim Str_name As String
Dim Str_password As String
Dim Str_username As String
Dim Str_userpassword As String
Dim Remainday As Long
Str_name = txt_name.Text
Str_password = txt_password.Text
Set Mydb = ExeCutesql("select user from user1 where user='" & Str_name & "'", Str_text)
If Mydb.EOF Then
MsgBox "你输入的用户名不存在,请重新输入!", vbOKOnly + 32, "注意"
txt_name = ""
txt_password = ""
txt_name.SetFocus
Else
Set Mydb1 = ExeCutesql("select user,pass from user1 where user='" & Str_name & "'", Str_text)
Str_username = Trim(Mydb1.Fields(0))
Str_userpassword = Trim(Mydb1.Fields(1))
If Trim(Str_password) = Str_userpassword Then
frm_main.Show
Mydb.Close
Mydb1.Close
Set Mydb = Nothing
Set Mydb1 = Nothing
Unload Me
Else
MsgBox "你输入的密码错误,请重新输入!", vbOKOnly + 32, "注意"
txt_password.SetFocus
End If
End If
End Sub
运行时出现错误:错误3704,对象关闭时不允许操作!
错误代码:If Mydb.EOF Then
求教各位高手大侠!!! 展开
1个回答
展开全部
字符串么?像是没有赋值。
另外,当Dim 记录集的时候已经DIM成New ADODB.RecordSet后,使用时就不必再SET 为New ADODB.RecordSet了。
一般我使用ADO的时候是用
Dim Rs AS New ADODB.RecordSet
Dim CN As New ADODB.Connection
dim StrData as String '数据库边接字串
Dim sqlTxt as string '将要被执行的SQL语句
....
cn.connectionstring=strdata
cn.open
sql="SELECT....."
Rs.open sql,cn,1,1 '只读,是否只读在于后面两个参数。
另外,当Dim 记录集的时候已经DIM成New ADODB.RecordSet后,使用时就不必再SET 为New ADODB.RecordSet了。
一般我使用ADO的时候是用
Dim Rs AS New ADODB.RecordSet
Dim CN As New ADODB.Connection
dim StrData as String '数据库边接字串
Dim sqlTxt as string '将要被执行的SQL语句
....
cn.connectionstring=strdata
cn.open
sql="SELECT....."
Rs.open sql,cn,1,1 '只读,是否只读在于后面两个参数。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询