ADO Problem - No Data Returned

From: John C. Frickson (bogus.email_at_bogus.domain.com)
Date: 08/16/04


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;
}



Relevant Pages

  • Re: May I please interrupt?
    ... We simply move money from Account A to ... Account B to Account C to Account D - ad infinitum. ... production to become a country that revolves ... the American manufacturing base from someone (I'm not saying YOU ...
    (rec.sport.football.college)
  • Re: Picture Manager need help
    ... PSS charges too much, and I'd have to justify not only MS's charge, ... but the cost of my time, to my clients. ... The production folks would love me ... > account will be deleted without reading. ...
    (microsoft.public.office.misc)
  • Re: User Security Question
    ... the foot with the large amount of unauthorised changes it makes to the ... account ... DBA thinks this isn't possible. ... As a general rule developers should have update access to production ...
    (comp.databases.oracle.misc)
  • Re: May I please interrupt?
    ... We simply move money from Account A to ... Account B to Account C to Account D - ad infinitum. ... production to become a country that revolves ... the American manufacturing base from someone (I'm not saying YOU ...
    (rec.sport.football.college)
  • Re: User Security Question
    ... account ... application user account without making changes to the account or ... As a general rule developers should have update access to production ... Time is money. ...
    (comp.databases.oracle.misc)

Loading