| 根据不同的SQL语句获取记录集 |
|
| 作者:Grant 文章来源:IT学院 点击数: 本日:{$DayHits} 更新时间:2006-11-21 22:41:17 |
根据不同的SQL语句获取记录集
Public Function GetRS(ByVal strQuery As String) As ADODB.Recordset Dim RS As New ADODB.Recordset Dim conn As New ADODB.Connection On Error GoTo GetRS_Error Set conn = CurrentProject.Connection RS.Open Trim$(strQuery), conn, adOpenKeyset, adLockOptimistic Set GetRS = RS
GetRS_Exit: RS.Close Set RS = Nothing conn.Close Set conn = Nothing Exit Function GetRS_Error: MsgBox (Err.Description) Resume GetRS_Exit End Function
'用法示例: Dim RS As New ADODB.Recordset Dim str As String str = "select * from 员工表" Set RS = GetRS(str) '对记录集的相关操作…… ……
RS.Close Set RS=Nothing
|
| 文章录入:tm 责任编辑:tm |
|
上一篇文章: 如何通过代码判断一条记录是否被选择
下一篇文章: 批量去除通过ODBC连接到SQL Server链接表名前的"DBO_" |
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |