ADODB fetch all records into client machine virtual memory

hasmukh

New Member
Joined
Jul 13, 2021
Messages
1
Office Version
  1. 2016
  2. 2011
  3. 2010
Platform
  1. Windows
I am using ADODB C++ for Execute Query like Select * from table. This table having the large data around 4GB. So when i Execute Query then it is fetching all the records and increase heap memory and load all the records on the client machine virtaul memory.
this is my code

// **Create Record set Object**
ADODB::_RecordsetPtr m_pRecordSetData= NULL;
HRESULT hr = m_pRecordSetData.CreateInstance(__uuidof(ADODB::Recordset));
m_pRecordSetData->CursorType = ADODB::adOpenStatic;
m_pRecordSetData->CursorLocation = ADODB::adUseClient;
m_pRecordSetData->LockType = ADODB::adLockReadOnly;

**// Create Command Object**
ADODB::_CommandPtr pCmdPtr = NULL;
HRESULT hr = pCmdPtr.CreateInstance(__uuidof(ADODB::Command));
if (FAILED(hr))
{
return pCmdPtr;
}
pCmdPtr->PutCommandType(ADODB::adCmdText);
pCmdPtr->PutCommandTimeout(0);
pCmdPtr->ActiveConnection = m_pConnection;
pCmdPtr->CommandText = L"Select * from Table";

**// Execute Query Select * from table**
_variant_t vtConn;
vtConn.vt = VT_ERROR;
vtConn.scode = DISP_E_PARAMNOTFOUND;
HRESULT hr = m_pRecordSetData->Open((_variant_t((IDispatch *)pCmdPtr)), vtConn,
ADODB::adOpenStatic, ADODB::adLockReadOnly, -1);




So When We execute last line Recordset Open this will block until all the record is fetched. So it consume all the heap memory of the system.

**Expectation / Requirement : Can we fetch the record batch wise / few rows only? , So we can allocated that heap memory and release it. So this will not consume all client side heap memory. Can we fetch asynchronously we will get the next record in batch wise? So we don't want to fetch all record in one go.**
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,223,901
Messages
6,175,277
Members
452,629
Latest member
SahilPolekar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top