🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
4 messages
4 total messages Started by Carlos Fri, 01 Dec 2006 16:35
How can I catch EDataBaseError : "Field '%s' must have a value"
#2845
Author: Carlos
Date: Fri, 01 Dec 2006 16:35
6 lines
1015 bytes
Hello,

I would like silent this exception on global app.
Is it possible ?

Regards 
Re: How can I catch EDataBaseError : "Field '%s' must have a value"
#2846
Author: 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
Re: How can I catch EDataBaseError : "Field '%s' must have a value"
#2848
Author: Carlos
Date: Sat, 02 Dec 2006 12:40
55 lines
2762 bytes
Hello Vladimir,

I want do it on the system level. I don�t want rewrite a PostError event
for all components.

Thank you

"Vladimir Stefanovic" <antivari@po.sbb.co.yu> escribi� en el mensaje 
news:45706cdd$1@newsgroups.borland.com...
>> 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
>
>
> 
Re: How can I catch EDataBaseError : "Field '%s' must have a value"
#2849
Author: Vladimir Stefanovic
Date: Sat, 02 Dec 2006 14:29
21 lines
1539 bytes
> I want do it on the system level.
> I don�t want rewrite a PostError event for all components.

You can have only *one* common OnPostError() for every
database component (not tested, but I'm prety sure)

Then you can say:

void __fastcall TDataModule::SharedADODataSetPostError(TDataSet *DataSet,
     EDatabaseError *E, TDataAction &Action)
{
  Action = daAbort;
}

Just select this event form every ADO dataset object.



-- 
Best Regards,
Vladimir Stefanovic
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads