Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3026

GetFieldValue is too slow

$
0
0
I read from MS SQL Server using CDaoRecodset. There is a shortcode:

Code:

CDaoDatabase *db;
db = new CDaoDatabase();
db->Open(NULL, FALSE, FALSE, _T("DRIVER={SQL Server Native Client 11.0};SERVER=10.9.70.246\\SQLSERVER;DATABASE=DDTSZDC;UID=sa;PWD=abcd;"));
CString query;
query.Format(_T("SELECT address,object,type FROM Data WHERE (adresa IN (%s)) ORDER BY cas ASC;"),Filter);
rs = new CDaoRecordset(db);
rs->Open(dbOpenDynaset, query);
COleVariant set;
if (rs->IsOpen()) {
while (!rs->IsEOF()) {
        rs->GetFieldValue(0, set);
        ret0 = polozka.lVal;
        rs->GetFieldValue(1, set);
        ret1 = polozka.lVal;
        rs->GetFieldValue(2, set);
        ret2 = (LPWSTR)polozka.pbstrVal;
        ....... // some action
        rs->MoveNext();
};
rs->Close();
};
db->Close()

Execution of query is very quick, but calling of any GetFieldValue is too slow. Reading of 15000 records takes about 5 minutes. Is there any solution for quick reading of records from MS SQL Server db table?
It is not nessessary to use CDaoRecordset, but this is very simple. Can anybody write suitable code whitch connects databese and reads records from MS SQL Server some quick way?
Yhank you ...

Viewing all articles
Browse latest Browse all 3026

Trending Articles