LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 441
Default How query a disconnected ADO recordset - possible?

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
query a recordset SAm Excel Discussion (Misc queries) 2 May 1st 07 09:33 PM
Type recordset/recordset? FlaviusFlav[_9_] Excel Programming 4 May 24th 04 12:16 PM
Copy recordset from an Access "make table" query Laurie[_4_] Excel Programming 1 February 5th 04 09:45 AM
DAO query/recordset returns with field names Seth[_4_] Excel Programming 0 August 18th 03 08:36 PM


All times are GMT +1. The time now is 09:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"