VB6 SQL参数化查询模块
来源:互联网 发布:linux6 域名对应多个ip 编辑:程序博客网 时间:2024/06/07 14:06
Public Function AdoOpenRS(ByRef wADORecordSet As ADODB.Recordset, _
sqlSELECTCommand As String, _
Optional Param As Variant = , _
Optional ActiveADOConn As ADODB.Connection = Nothing, _
Optional ShowMsgBoxIfFail As Boolean = True, _
Optional CloseRSIfFail As Boolean = True, _
Optional SetRSNothingIfFail As Boolean = True, _
Optional sRetErrDesp As String = ) As Boolean
'Param 参数数组11 On Error GoTo errOpenRs
If Len(sqlSELECTCommand) = 0 Then Exit Function
If TypeName(Param) = Variant() Then
Dim i As Byte
For i = 1 To UBound(Param)
sqlSELECTCommand = Replace(sqlSELECTCommand, ? & i, Param(i))
Next
End If
wADORecordSet.CursorLocation = adUseClient '客户端游标
If ActiveADOConn Is Nothing Then
wADORecordSet.Open sqlSELECTCommand, SQLConn, adOpenDynamic, adLockOptimistic
Else
wADORecordSet.Open sqlSELECTCommand, ActiveADOConn, adOpenDynamic, adLockOptimistic
End If
Exit Function
errOpenRs:
If ShowMsgBoxIfFail Then MsgBox Err.Description, vbExclamation, ErrOpenRs
'If CloseRSIfFail Then wADORecordSet.Close
If SetRSNothingIfFail Then Set wADORecordSet = Nothing35 End Function
调用例子:
Dim strsql As String
Dim Param(1 To 1) As Variant
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
strsql = select OrderID From [Order] & _
where convert(nvarchar(7),OrderDate,120) = '?1'
Param(1) = Format(Now, YYYY-MM)
AdoOpenRS rs, strsql, Param
sqlSELECTCommand As String, _
Optional Param As Variant = , _
Optional ActiveADOConn As ADODB.Connection = Nothing, _
Optional ShowMsgBoxIfFail As Boolean = True, _
Optional CloseRSIfFail As Boolean = True, _
Optional SetRSNothingIfFail As Boolean = True, _
Optional sRetErrDesp As String = ) As Boolean
'Param 参数数组11 On Error GoTo errOpenRs
If Len(sqlSELECTCommand) = 0 Then Exit Function
If TypeName(Param) = Variant() Then
Dim i As Byte
For i = 1 To UBound(Param)
sqlSELECTCommand = Replace(sqlSELECTCommand, ? & i, Param(i))
Next
End If
wADORecordSet.CursorLocation = adUseClient '客户端游标
If ActiveADOConn Is Nothing Then
wADORecordSet.Open sqlSELECTCommand, SQLConn, adOpenDynamic, adLockOptimistic
Else
wADORecordSet.Open sqlSELECTCommand, ActiveADOConn, adOpenDynamic, adLockOptimistic
End If
Exit Function
errOpenRs:
If ShowMsgBoxIfFail Then MsgBox Err.Description, vbExclamation, ErrOpenRs
'If CloseRSIfFail Then wADORecordSet.Close
If SetRSNothingIfFail Then Set wADORecordSet = Nothing35 End Function
调用例子:
Dim strsql As String
Dim Param(1 To 1) As Variant
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
strsql = select OrderID From [Order] & _
where convert(nvarchar(7),OrderDate,120) = '?1'
Param(1) = Format(Now, YYYY-MM)
AdoOpenRS rs, strsql, Param
0 0
- VB6 SQL参数化查询模块
- VB6中数据库参数化查询的技巧
- SQL参数化查询
- SQL参数化查询
- SQL参数化查询
- sql参数化查询
- SQL参数化查询
- SQL参数化查询
- SQL参数化查询
- SQL(参数化)的查询
- 参数化的SQL查询
- 使用参数化查询 sql
- 【SQL】拼接SQL语句-参数化查询-模糊查询
- SQL参数化查询讲座 (一)
- SQL参数化查询讲座 (二)
- SQL参数化查询讲座 (三)
- SQL参数化查询讲座 (四)
- SQL参数化查询讲座 (五)
- 福州118个地名解读
- Linux版主机卫士安装使用
- Android EventBus实战
- 感悟--2015/6/9
- linux 内核同步机制-自旋锁与信号量及其区别
- VB6 SQL参数化查询模块
- 一目了然的几种join方式举例
- android jsonrpc 使用实例
- Scala学习笔记——不停更新中。。。
- ##android sdk 文件目录含义介绍
- Android Ant打包及其环境变量配置
- 合并两个排序的单链表
- java.util.concurrent.locks.LockSupport
- Android sdk content loader 0%的解决方案