Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have the following subroutine which calls the following function. This
opens an ADO connection and creates a disconnected recordset that is passed back to the calling sub. QUESTION: Is it possible to now query the disconnected recordset? If so, how do I create a connection to the recordset? Could someone please add the code needed to do so in the following Subroutine? Thanks much in advance... Private Sub btnRun_Click() Dim strSQL As String Dim rsADO As Recordset strSQL = "SELECT EMPLID FROM PSADM.PS_EMPLOYEES WHERE EMPLID = '999999999';" Set rsADO = RunQuery(strSQL) End Sub Public Function RunQuery(argSQL) As ADODB.Recordset Dim cnADO As Connection Dim rsADO As Recordset Set cnADO = New ADODB.Connection cnADO.CursorLocation = adUseClient cnADO.ConnectionString = "PROVIDER="";DRIVER={DriverName};SERVER=ServerName ;DBQ=DBQName;UID=;PWD=;" cnADO.CommandTimeout = 0 cnADO.Open Set rsADO = New ADODB.Recordset rsADO.MaxRecords = 0 '0 = everything Set rsADO = cnADO.Execute(argSQL) Set rsADO.ActiveConnection = Nothing 'Disconnect rs Set RunQuery = rsADO.Clone(adLockReadOnly) If rsADO.State = adStateOpen Then rsADO.Close Set rsADO = Nothing cnADO.Close Set cnADO = Nothing End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
query a recordset | Excel Discussion (Misc queries) | |||
Type recordset/recordset? | Excel Programming | |||
Copy recordset from an Access "make table" query | Excel Programming | |||
DAO query/recordset returns with field names | Excel Programming |