An Oracle client with the OpenforwardOnly flag connected to the database.

I am migrating an existing Windows-based C ++ application to a 64-bit environment, and this is one of those weird errors. You can use in the code snippet openforwardonly, and it worked fine with our old installation, but in a 64-bit environment it gives the problem of choosing only ONE set . Or it could be a problem with MoveNext();ADO.

To get around this, we started using adOpenStatic, and it worked fine for me for a while, but only later realized that it has a performance hit, and it takes forever to get / iteratively through the values. I ask someone to try this code with both flags and check the behavior that I see.

Ado Flags Information: http://www.w3schools.com/ADO/met_rs_open.asp

Another EE topic http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_DB/Q_11520558.html

I remember how I saw the MS support application, but right now I can’t do it.

I would be grateful for any help or suggestions. I know that we are using old technologies, but we want to move on to additional features without changing the code.

// Dbtest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <time.h>

#import "C:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")

int main(int argc, char* argv[])
{  
    HRESULT hr = S_OK;
    try
    {
        CoInitialize(NULL);

        _bstr_t strCnn("Provider=OraOLEDB.Oracle;Data Source =****; User Id=****; password=***");
        _ConnectionPtr m_pConn;

        hr=m_pConn.CreateInstance(__uuidof(Connection));

        if(FAILED(hr))
        {
            printf("Failed creating record set instance\n");
            return 0;
        }

        m_pConn->Open(strCnn,"","",NULL);

        //Open the Record set for getting records from Author table
        _RecordsetPtr pRstDoctors = NULL;
        time_t start,end1,end2;
        pRstDoctors.CreateInstance(__uuidof(Recordset));
        time(&start);

        pRstDoctors->Open("select logid from log",strCnn, adOpenForwardOnly,
                  **adLockReadOnly**,adCmdText);

        //Declare a variable of type _bstr_t

        int valField1;
        //int valField2;

        pRstDoctors->MoveFirst();

        //Loop through the Record set
        if (!pRstDoctors->EndOfFile)
        {
            while(!pRstDoctors->EndOfFile)
            {
                valField1 = pRstDoctors->Fields->GetItem("logid")->Value.intVal;
                // valField2 = pRstDoctors->Fields->GetItem("reportid")->Value.intVal;
                // printf("%d - \n",valField1);
                pRstDoctors->MoveNext();
            }
        }
        time(&end1);

        double dif=difftime(end1,start);
        printf("time difference is %.2lf",dif);
    }
    catch(_com_error e)
    {
        printf("Error:%s\n",e);
    }

    CoUninitialize();
    return 0;
}
+3
source share
1 answer

Using "adOpenStatic" instead of "adOpenForwardOnly" will work

pRstDoctors->Open("select logid from log",strCnn, adOpenStatic,
               **adLockReadOnly**,adCmdText);
+1
source

Source: https://habr.com/ru/post/1698684/


All Articles