🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #938

TADOTable & TADOQuery: OnPost() errors...

#938
From: Vladimir Stefanovic
Date: Mon, 21 Mar 2005 14:54
95 lines
3371 bytes
Hi,

How do you catch errors in TADOTable's/TADOQuery's
OnPost() or OnDelete()? Is there something better that
the way I already use (as you can see, for now I'm parsing
the E->Message):

void __fastcall TMainDB::SomeTblPostError(TDataSet *DataSet,
      EDatabaseError *E, TDataAction &Action)
{
   // No system error message
   Action = daAbort;

   if ( StrPos( E->Message.c_str(), 
C(IDS_SER_DBSTR_E_MSG_DUPLICATE_VALUES).c_str() ) != NULL )
   {
      // MESSAGE: ...
      return;
   }

   if ( StrPos( E->Message.c_str(), 
C(IDS_SER_DBSTR_E_MSG_ZERO_LENGTH).c_str()       ) ||
        StrPos( E->Message.c_str(), 
C(IDS_SER_DBSTR_E_MSG_NULL_VALUE).c_str()        ) ||
        StrPos( E->Message.c_str(), 
C(IDS_SER_DBSTR_E_MSG_MUST_HAVE_A_VALUE).c_str() ) ||
        StrPos( E->Message.c_str(), 
C(IDS_SER_DBSTR_E_MSG_ERROR_IN_ROW).c_str()      ) ||
        StrPos( E->Message.c_str(), 
C(IDS_SER_DBSTR_E_MSG_EMPTY_ROW_CANNOT_BE_INSERTED).c_str() ) )
   {

      if ( StrPos( E->Message.c_str(), "SomeTableField" ) )
      {
         // MESSAGE: ...
         return;
      }

      if ( StrPos( E->Message.c_str(), "SomeOtherTableField" ) )
      {
         // MESSAGE: ...
         return;
      }

      // MESSAGE: New row cannot remain empty ...

      return;
   }

   // 
***********************************************************************
   // If none of errors identified ...
   // 
***********************************************************************
   ShowMessage( "Unknown error: " + E->Message );
   return;
}

The C() returns some of the strings defined here:


   IDS_SER_DBSTR_E_MSG_DUPLICATE_VALUES,
      "duplicate values";

   IDS_SER_DBSTR_E_MSG_ZERO_LENGTH,
      "zero-length";

   IDS_SER_DBSTR_E_MSG_NULL_VALUE,
      "Null value";

   IDS_SER_DBSTR_E_MSG_MUST_HAVE_A_VALUE,
      "must have a value";

   IDS_SER_DBSTR_E_MSG_ERROR_IN_ROW,
      "Error in row";

   IDS_SER_DBSTR_E_MSG_INCLUDES_RELATED_RECORDS
      "includes related records";

   IDS_SER_DBSTR_E_MSG_EMPTY_ROW_CANNOT_BE_INSERTED,
      "Empty row cannot be inserted";

   IDS_SER_DBSTR_E_MSG_NOT_A_VALID_DATE_AND_TIME,
      "not a valid date";

   IDS_SER_DBSTR_E_MSG_DATETIME_FIELD_OVERFLOW,
      "Datetime field overflow";

   IDS_SER_DBSTR_E_MSG_ROW_MUST_HAVE_AT_LEAST_ONE_COLUMN,
      "Row must have at least one column";


-- 
Best regards,
Vladimir Stefanovic 
Technical Details
Message-ID: <423ee030@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,3e7ff731bb780857,start
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Vladimir Stefanovic" <antivari@po.sbb.co.yu>
Newsgroups: borland.public.cppbuilder.database.ado
Subject: TADOTable & TADOQuery: OnPost() errors...
Date: Mon, 21 Mar 2005 15:54:50 +0100
Lines: 97
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 82.117.212.65
Message-ID: <423ee030@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1111416880 82.117.212.65 (21 Mar 2005 06:54:40 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail