既存の Windows ベースの C++ アプリケーションを 64 ビット環境に移植していますが、これは奇妙なエラーの 1 つです。私が使用しているコード スニペットでは、以前のセットアップで問題なく動作していましたが、64 ビット環境では 1 つのレコードopenforwardonly
セットしか取得できないという問題が発生します。または、ADOの問題である可能性があります。MoveNext();
それを回避するために を使用し始めadOpenStatic
、しばらくの間は問題なく機能しましたが、後でパフォーマンスに影響があり、値を取得/反復するのに永遠に時間がかかっていることに気付きました。両方のフラグでこのコードを試して、私が見ている動作を検証するよう誰かに依頼します。
ado フラグに関する情報: http://www.w3schools.com/ADO/met_rs_open.asp
別の EE トピック http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_DB/Q_11520558.html
MS のサポート ケースを見た覚えがありますが、今は入手できません。
助けや提案をいただければ幸いです。古いテクノロジーを使用していることは承知していますが、コードをあまり変更せずに追加機能に移行したいと考えています。
// 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;
}