🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #2846

Re: How can I catch EDataBaseError : "Field '%s' must have a value"

#2846
From: Vladimir Stefanovic
Date: Fri, 01 Dec 2006 17:57
43 lines
2468 bytes
> I would like silent this exception on global app.

Do you have the source code, or you want to suppress
that message on the system level ?

If you have the source code, that depends on the database
system you use. For example, for ADO:

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

   // ... other checkings ...

   // ...
   if ( StrPos( E->Message.c_str(), "zero-length"                  ) ||
        StrPos( E->Message.c_str(), "Null value"                   ) ||
        StrPos( E->Message.c_str(), "must have a value"            ) ||
        StrPos( E->Message.c_str(), "Error in row"                 ) ||
        StrPos( E->Message.c_str(), "not a valid date"             ) ||
        StrPos( E->Message.c_str(), "Datetime field overflow"      ) ||
        StrPos( E->Message.c_str(), "related record is required "  ) ||
        StrPos( E->Message.c_str(), "Empty row cannot be inserted" ) )
   {
      if ( StrPos( E->Message.c_str(), "SomeField" ) )
      {
         ShowMessage( "Field 'SomeField' must have a value" );
         return;
      }
      if ( StrPos( E->Message.c_str(), "OtherField" ) )
      {
         // ... etc ...
      }
      ShowMessage( "Record must not be empty!\n\n" + E->Message );
      return;
   }
   ShowMessage( "Unknown Error.\n\n" + E->Message );
}
-- 
Best Regards,
Vladimir Stefanovic
Technical Details
Message-ID: <45706cdd$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <457059b9@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,7a3f4138c63144de
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Vladimir Stefanovic" <antivari@po.sbb.co.yu>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <457059b9@newsgroups.borland.com>
Subject: Re: How can I catch EDataBaseError : "Field '%s' must have a value"
Date: Fri, 1 Dec 2006 18:57:18 +0100
Lines: 46
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; Response
NNTP-Posting-Host: 89.216.237.0
Message-ID: <45706cdd$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1164995805 89.216.237.0 (1 Dec 2006 09:56:45 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail