ADO Problem - No Data Returned
From: John C. Frickson (bogus.email_at_bogus.domain.com)
Date: 08/16/04
- Next message: wanghg: "how to get the rowset by using ODBC API function"
- Previous message: Sagar: "Can you pls read and help on the Windows Servcie ?."
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 16 Aug 2004 20:27:41 GMT
I have a function similar to what I've included below. In production use,
it randomly fails giving the "No Data Found" error, even though the
account exists in the database. Rerunning the job (sometimes multiple
times) will eventually get past the error.
Does anyone have any idea what's happening?
Thanks!
bool CSomeClass::GetDescr(char *acct)
{
long i;
bool ok = true;
CString qry;
CoInitialize(NULL);
try {
ADODB::_RecordsetPtr sqlRs("ADODB.Recordset");
_variant_t sqlQuery, val;
_bstr_t bval;
qry.Format("SELECT DESC FROM ACCOUNTS WHERE ACCOUNT = %s", acct);
sqlQuery = qry;
sqlRs->Open(sqlQuery,
"DSN=Cust;UID=uid;PWD=pwd",
ADODB::adOpenForwardOnly,
ADODB::adLockUnspecified,
ADODB::adOptionUnspecified);
if (sqlRs->EndOfFile) {
errorMessage("No Data Found");
CoUninitialize();
return false;
}
i = 1;
val = sqlRs->GetFields()->Item[i]->Value;
bval = val;
m_AcctDescr = (char*)bval;
sqlRs->Close();
}
catch (_com_error &e)
{
errorMessage("Error: Code = %08lx Code meaning = %s Source = %s "
"Description = %s", e.Error(), (char*)e.ErrorMessage(),
(char*)e.Source(), (char*)e.Description());
ok = false;
}
catch(...)
{
errorMessage("Unknown Error Occured");
ok = false;
}
CoUninitialize();
return ok;
}
- Next message: wanghg: "how to get the rowset by using ODBC API function"
- Previous message: Sagar: "Can you pls read and help on the Windows Servcie ?."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|