| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 9271 人关注过本帖
标题:运行时出现了“对象关闭时不允许操作”实时错误3704,请问大家怎么改呢?
取消只看楼主 加入收藏
ly21a
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2007-9-16
收藏
 问题点数:0 回复次数:1 
运行时出现了“对象关闭时不允许操作”实时错误3704,请问大家怎么改呢?

Option Explicit‘这是公共模块

Public adocon As ADODB.Connection
Public adminp As Boolean
Public readp As Boolean
Public username As String

Public Function executesql(ByVal sql As String) As ADODB.Recordset
Dim rst As ADODB.Recordset
Set adocon = New ADODB.Connection
adocon.CursorLocation = adUseClient
adocon.ConnectionString = Connstring
adocon.Open
Dim stokens() As String
On Error GoTo executesql_error
stokens = Split(sql, " ")
If InStr("inser,delete,update", UCase(stokens(0))) Then
adocon.Execute sql
Else
Set rst = New ADODB.Recordset
rst.Open Trim(sql), adocon, adOpenKeyset, adLockOptimistic
Set executesql = rst
End If
executesql_exit:
Set rst = Nothing
Set adocon = Nothing
Exit Function
executesql_error:
Resume executesql_exit

End Function

Public Function Connstring() As String

Connstring = "provider = microsoft.Jet.OLEDB.4.0;Data source =" & App.Path & "\123.mdb "
End Function
Public Function executeqx() As Boolean
Dim sql As String
Dim rst As ADODB.Recordset
Set adocon = New ADODB.Connection
adocon.ConnectionString = Connstring
adocon.Open
Set rst = New ADODB.Recordset
sql = "select * from use where username='" & username & "'"
rst.Open Trim(sql), adocon, adOpenKeyset, adLockOptimistic
If rst.EOF = True Then
MsgBox "非法用户", vbExclamation + vbOKOnly, "警告"
executeqx = Null
Exit Function
End If
If rst.Fields("admin") Then
executeqx = True
Exit Function
ElseIf rst.Fields("readonly") Then
executeqx = False
End If
rst.Close
On Error GoTo executesql_error
executesql_exit:
Set rst = Nothing
Set adocon = Nothing
Exit Function
executesql_error:
Resume exectuesql_exit

End Function


’这是登录窗体代码
Private Sub Command1_Click()
Dim txtsql As String
Dim mrc As New ADODB.Recordset
txtsql = "select username from use where username=" & Trim(Text1.Text) & ""
Set mrc = executesql(txtsql)
If mrc.EOF = True Then
MsgBox "用户名错误!", vbExclamation + vbOKOnly, "警告"
Text1.SetFocus
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Exit Sub
End If
username = mrc.Fields(0)
txtsql = "select username from use where password=" & Trim(Text2.Text) & ""
Set mrc = executesql(txtsql)
If mrc.EOF = True Then
MsgBox "密码错误!", vbExclamation + vbOKOnly, "警告"
Text2.SetFocus
Text2.SelStart = 0
Text2.SelLength = Len(Text1.Text)
Exit Sub
End If
If executeqx Then
adminp = True
Else
readp = True
End If

End Sub


Private Sub Command2_Click()
end
End Sub
运行时出现了“对象关闭时不允许操作”实时错误3704,请问大家怎么改呢?

搜索更多相关主题的帖子: 实时 Public adocon 对象 ADODB 
2007-09-18 09:36
ly21a
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2007-9-16
收藏
得分:0 
就我的这个程序,怎么改呢?
2007-09-20 20:53
快速回复:运行时出现了“对象关闭时不允许操作”实时错误3704,请问大家怎么改呢 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018175 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved