|
在access2000定义了以下函数在一个模块中,却不能调用不知何故
Public Function getrs(ByVal strquery As String) As ADODB.Recordset
'获得记录集
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
On Error GoTo getrs_error
Set conn = CurrentProject.Connection '打开当前连接
rs.Open strquery, conn, adOpenKeyset, adLockOptimistic, adCmdText
Set getrs = rs
getrs_exit:
Set rs = Nothing '释放当前连接与记录集
Set conn = Nothing
Exit Function
getrs_error:
MsgBox (Err.Description)
Resume getrs_exit
End Function
Public Sub executesql(ByVal strcmd As String) '试行sql语句
Dim conn As New ADODB.Connection
On Error GoTo executesql_error
Set conn = CurrentProject.Connection '打开当前连接
conn.Execute Trim$(strcmd)
executesql_exit:
Set conn = Nothing
Exit Sub
executesql_error:
MsgBox (Err.Description)
Resume executesql_exit
End Sub |
|