Thread View: borland.public.cppbuilder.database.ado
1 messages
1 total messages
Started by Vladimir Stefanovic
Mon, 21 Mar 2005 14:54
TADOTable & TADOQuery: OnPost() errors...
Author: Vladimir Stefanovic
Date: Mon, 21 Mar 2005 14:54
Date: Mon, 21 Mar 2005 14:54
95 lines
3371 bytes
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
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