把下面的代码加到类模块里
Option Explicit
Public cn As ADODB.Connection
Public rs As ADODB.Recordset
Public rspt As ADODB.Recordset
Public a As String
Public Function conn() As Boolean
Set cn = New Connection
On Error GoTo cnerr
Dim connect As Boolean
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\system.ini;"
cn.ConnectionTimeout = 20
cn.Open
conn = True
Exit Function
cnerr:
conn = False
MsgBox Err.Description
End Function
Public Function openrs(ByVal sqlstr As String) As Boolean
Set rs = New Recordset
On Error GoTo rserr
rs.Open sqlstr, cn, adOpenDynamic, adLockOptimistic, -1
openrs = True
Exit Function
rserr:
openrs = False
MsgBox Err.Description
End Function
[此贴子已经被作者于2006-3-30 13:16:52编辑过]