Example: lrc_print_recordset

This example prints all rows of a recordset.

{
// Creating Recordset COM object (ADO)
        GUID pClsid = lrc_GUID("ADODB.Recordset.2.6");
        IUnknown * pUnkOuter = (IUnknown*)NULL;
        unsigned long dwClsContext = lrc_ulong("5");
        GUID riid = IID_IUnknown;
        lrc_CoCreateInstance(&pClsid, pUnkOuter, dwClsContext, &riid, (void**)&IUnknown_0, CHECK_HRES);
    }
// Query for IDispatch interface from the IUnknown interface we got before
    {
        GUID riid = IID_IDispatch;
        lrc_IUnknown_QueryInterface(IUnknown_0, &riid, (void**)&IDispatch_0, CHECK_HRES);
    }
// Query for IRecordset interface from the IDispatch interface we got before
    {
        GUID riid = IID__Recordset;
        lrc_IDispatch_QueryInterface(IDispatch_0, &riid, (void**)&_Recordset_0, CHECK_HRES);
    }
// Call Open method of IRecordset interface on _Recordset_0 instance in order 
// to fill it with data
    {
        int CursorType = lrc_int("-1");
        int LockType = lrc_int("-1");
        long Options = lrc_long("-1");
        VARIANT Source = lrc_variant_BSTR("SELECT AGENT_NAME FROM AGENTS GROUP BY AGENT_NAME");
        VARIANT ActiveConnection = lrc_variant_BSTR("DSN=flight32lr");
        lrc__Recordset_Open(_Recordset_0, Source, ActiveConnection, CursorType, LockType, Options, CHECK_HRES);
    }
// print the returned data
    lrc_print_recordset((Recordset15*)_Recordset_0, -1);