views:

246

answers:

0

Hi, I am porting an existing windows based C++ application to 64 bit environment and this is one of those weird errors. In the code snippet you can that I am using openforwardonly and it used to work fine with our old setup but in the 64 bit environment it gives the problem of fetching only ONE recordset. Or it could be a problem with the MoveNext(); of ADO.

To circumvent it 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 is taking forever to get/iterative through values. I request someone to try this code with both the flags and validate the behavior I am seeing.

Information about ado flags: 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 seeing a MS support case but I can't get to it now.

I would appreciate any help or suggestions. I know we are using old technology but we want to move to the additional capabilities without changing code much.

// 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;
}