📄 querydao.cls
字号:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "QueryDAO"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'**************************************
'* 模 块 名 称 :查询模块数据库操作
'* 功 能 描 述 :查询模块中所有的查询操作在此模块中定义
'* 程序员姓名 : 陈齐国
'* 最后修改人 : 陈齐国
'* 最后修改时间:2005/08/27
'**************************************
Option Explicit
'**************************************
'* 功 能 描 述 :根据条件查询视图
'* 输 入 参 数 :无
'* 输 出 能 数 :True - 数据库连接成功
'* False - 数据库连接失败
'**************************************
Public Function ExecuteQuery(recSet As ADODB.Recordset, sqlStr As String) As Boolean
On Error GoTo Cwcl
' 执行查询
recSet.Open sqlStr, MainForm.g_application.m_databaseCon.m_adoConnection, _
adOpenStatic, adLockOptimistic, adAsyncFetch
ExecuteQuery = True
Exit Function
Cwcl:
ExecuteQuery = False
Exit Function
End Function
'**************************************
'* 功 能 描 述 :把查询用的ID列表字符串中的所有ID插入到temp_QueryIdList表中
'* 输 入 参 数 :idList - 查询到要显示的记录ID的列表字符串
'* 输 出 能 数 :
'**************************************
Public Function InsertQueryIdList(idList As String)
Dim tempStr As String ' 中间字符串
Dim idStr As String ' 取出的一个ID
Dim found As Integer
DelQueryIdList ' 删除temp_QueryIdList表中的所有记录
tempStr = idList
Do While Not Trim(tempStr) = ""
found = InStr(tempStr, ",")
If found <> 0 Then
If found > 1 Then idStr = Left(tempStr, found - 1)
tempStr = Right$(tempStr, Len(tempStr) - found)
Else
idStr = tempStr
tempStr = ""
End If
NewQueryId (idStr)
Loop
End Function
'**************************************
'* 功 能 描 述 :新增一条查询ID到temp_QueryIdList表中
'* 输 入 参 数 :queryId - ID值
'* 输 出 能 数 :
'**************************************
Private Function NewQueryId(queryId As String)
Dim cmdProc As ADODB.Command ' 执行存储过程的命令
Set cmdProc = New ADODB.Command
Set cmdProc.ActiveConnection = MainForm.g_application.m_databaseCon.m_adoConnection
' 执行存储过程的命令的设置
cmdProc.CommandText = "temp_QueryIdList_new" ' 指定存储过程的名子
cmdProc.CommandType = adCmdStoredProc
cmdProc.Parameters.Refresh
cmdProc.Parameters(1) = queryId ' 参数
' 执行命令 把查询到的结果放在recSet中
On Error GoTo Cwcl
cmdProc.Execute
Set cmdProc = Nothing
Exit Function
Cwcl:
Set cmdProc = Nothing
End Function
'**************************************
'* 功 能 描 述 :删除temp_QueryIdList表中的所有记录
'* 输 入 参 数 :
'* 输 出 能 数 :
'**************************************
Private Function DelQueryIdList()
Dim cmdProc As ADODB.Command ' 执行存储过程的命令
Set cmdProc = New ADODB.Command
Set cmdProc.ActiveConnection = MainForm.g_application.m_databaseCon.m_adoConnection
' 执行存储过程的命令的设置
cmdProc.CommandText = "temp_QueryIdList_deleteAll" ' 指定存储过程的名子
cmdProc.CommandType = adCmdStoredProc
cmdProc.Parameters.Refresh
' 执行命令 把查询到的结果放在recSet中
On Error GoTo Cwcl
cmdProc.Execute
Set cmdProc = Nothing
Exit Function
Cwcl:
Set cmdProc = Nothing
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -