I read from MS SQL Server using CDaoRecodset. There is a shortcode:
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 ...
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()
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 ...