1,216
社区成员
发帖
与我相关
我的任务
分享
public sub Click()
dim strSQL = "
Declare @NameList varchar(255)
Set @NameList='''测试员'''
Exec( 'Select * from BM_NestManage_Role Where RoleName in (' + @NameList + ') and LogoutFlag = 0')"
Dim ccn As ADODB.Connection
Set ccn = DB.OpenDB(DB_BM.DB_CONN)
Dim rs As ADODB.Recordset
'---------------------------------------------------------
' 得不到
Set rs = DB.QueryTable(strSQL, cn)
' -----------------------------------------------------
If rs Is Nothing Then
Exit Function
End If
If rs.RecordCount = 0 Then
Call DB.CloseQuery(rs)
Exit Function
End If
end sub
Public Function QueryTable(strSQL As String, CurCn As ADODB.Connection) As ADODB.Recordset
On Error Resume Next
Set QueryTable = Nothing
Set rs = New ADODB.Recordset
rs.Open strSQL, CurCn, adOpenKeyset, adLockReadOnly
If Err.Number <> 0 Then
MsgBox "不能查询数据库!" + Chr(10) + Chr(13) + Err.Description
Err.Clear
Debug.Print strSQL
Set rs = Nothing
Exit Function
End If
'如果记录集处于关闭状态
If rs.State = 0 Then
Set rs = Nothing
End If
Set QueryTable = rs
Debug.Print strSQL
End Function