Hi,
I get some value from database with ADO:
HRESULT hr;
::CoInitialize(NULL);
_ConnectionPtr pConn("ADODB.Connection");
_RecordsetPtr pRs;
hr = pConn->Open("dsn=MySource;uid=sa;pwd=", "", "", adAsyncConnect);
if(FAILED(hr))
{
AfxMessageBox("Error");
return;
}
try
{
_variant_t vRowsAffected;
pRs = pConn->Execute("select min(myID) from MyTable",
&vRowsAffected, adCmdText);
_variant_t vtIndex;
_variant_t vtField;
vtIndex.vt = VT_I2;
vtIndex.iVal = 0;
vtField = pRs->Fields->GetItem(vtIndex)->Value;
if(vtField.vt != VT_NULL);
TRACE("VALUE = %d\n", vtField.iVal);
}
catch(_com_error &e)
{
dump_com_error(e);
}
::CoUninitialize();
when I open connection with adAsyncConnect, pConn->Execute will throw an error. With adConnectUnspecified will work OK, but speed is very slow, more slow than ODBC.
My question is why I can?t use Execute() with asynchronously opening connection?
Or Which is the max speed method to get value from database?
Thank you.
P.S. the MSDN ADO pages is here: http://www.msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/dasdkadooverview.asp?frame=true
My 2 cents...