Error Canceling post in OnBeforePost event

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
bedla.czech

Error Canceling post in OnBeforePost event

Post by bedla.czech » Fri 08 Jul 2005 10:18

Hi,

I am testing Trial version of your VCL components. When I call Insert method or just start editing row and then move to other row and than cancel the insert or update operation it will always insert new row! Am I doing something wrong?

thanks

Code: Select all

void __fastcall TForm1::Button1Click(TObject *Sender)
{
 MyTable1->Insert();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
  MyTable1->Post();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
  MyTable1->Delete();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::MyTable1BeforePost(TDataSet *DataSet)
{
 if ( !DataSet )
  return ;

 if ( !( DataSet->State == dsEdit || DataSet->State == dsInsert ) )
  return ;

 AnsiString strMessage = "";

 switch ( DataSet->State )
 {
  case dsEdit:
   strMessage = "Editujete data, uložit zmìny?";
  break;
  case dsInsert:
   strMessage = "Vkládáte data, uložit zmìny?";
  break;
 } // end switch

 if ( MessageDlg(strMessage, mtConfirmation, TMsgDlgButtons() Cancel();

}
//---------------------------------------------------------------------------

bedla.czech

Post by bedla.czech » Fri 08 Jul 2005 11:12

it was my mistake :-(

this code works fine :-)

Code: Select all

void __fastcall TForm1::MyTable1BeforePost(TDataSet *DataSet)
{
 if ( !DataSet )
  return ;

 AnsiString strMessage = "";

 switch ( DataSet->State )
 {
  case dsEdit:
   strMessage = "Editujete data, uložit změny?";
  break;
  case dsInsert:
   strMessage = "Vkládáte data, uložit změny?";
  break;
 } // end switch

 int msgDlgResult = MessageDlg(strMessage, mtConfirmation, TMsgDlgButtons() Cancel();
   Abort();
  break;
  case mrCancel:
   Abort();
  break;
 } // end switch


}


Post Reply