Hi, I'm trying to execute a select query that takes about 5 seconds to execute, during that time a timer is running and it is not frozen however once the query is finished, the pRecordset variable returns nothing.
After the query is finished executing the code goes to the function named
Private Sub m_conn_ExecuteComplete (found last on the code)
but I can't seem to be getting a recordset with data even though the
RecordsAffected
parameter does return the count of how many records were returned.
I need to find out how to return data after the query executes(this it doesn't) AND asynchronously (this it does), any idea how I can get
pRecordset to return data?
Quote:
Private WithEvents m_conn As ADODB.Connection
Dim rs As Recordset
Option Explicit
Private Sub cmdRun_Click()
Dim b As Long
Dim strSql As String
Dim cn As Connection
Set cn = New ADODB.Connection
Set m_conn = New ADODB.Connection
Call m_conn.Open(Module1.ConnectString("servername", "dbname", "root", "pass"), , , adAsyncConnect)
Set rs = New ADODB.Recordset 'Creates record set
strSql = " select distinct stock_stockvalues.stockid from stock_stockvalues where stockid not in (select distinct trans_detail.stockid From Trans_Detail where trans_detail.datetime > '2007-05-19 00:00:00' and trans_detail.datetime < '2011-05-19 08:03:35')"
Call m_conn.Execute(strSql, , adAsyncExecute)
End Sub
Private Sub Timer_Timer()
StatusBar.Panels(1).Text = CStr(DateTime.Now)
End Sub
Private Sub m_conn_ExecuteComplete(ByVal RecordsAffected As Long, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pCommand As ADODB.Command, ByVal pRecordset As ADODB.Recordset, ByVal pConnection As ADODB.Connection)
//here is where the code goes after the query is finished, but, pRecordset returns nada!
End Sub
|
Thanks
