Board index » delphi » How to handle EDBEngine error key violation?

How to handle EDBEngine error key violation?

When attempting to filter a local Paradox table by ending the filter
criteria with
a wildcard written :
 s1:='Man*';
  tNames.Filter:='(Company = '+QuotedStr(s1)+')';
  tNames.Filtered:=true;
an error is generated if no records match the filter.  The error is
described "EDBEngine error.  Message Key violation"

An exception block does not seem to help:
  try
  tNames.Filter:='(Company = '+QuotedStr(s1)+')';
  tNames.Filtered:=true;
  except
   tNames.Filtered:=false;
  end;

The key violation comes up and I cannot find a way to clear it short of
exiting the application.  How can the error be cleared, and better,
automatically?

Thanks
Tore Fossum
tfos...@titrate.cc

 

Re:How to handle EDBEngine error key violation?


Quote
"Tore Fossum" <tfos...@titrate.cc> wrote in message news:3a613584_2@dnews...
> When attempting to filter a local Paradox table by ending the filter
> criteria with
> a wildcard written :
>  s1:='Man*';
>   tNames.Filter:='(Company = '+QuotedStr(s1)+')';
>   tNames.Filtered:=true;
> an error is generated if no records match the filter.  The error is
> described "EDBEngine error.  Message Key violation"

> An exception block does not seem to help:
>   try
>   tNames.Filter:='(Company = '+QuotedStr(s1)+')';
>   tNames.Filtered:=true;
>   except
>    tNames.Filtered:=false;
>   end;

> The key violation comes up and I cannot find a way to clear it short of
> exiting the application.  How can the error be cleared, and better,
> automatically?

> Thanks
> Tore Fossum
> tfos...@titrate.cc

A key violation occurs when your trying to insert a record where the index
has already been used. This will have nothing to do with the Filter
statement, which is the try..except block doesn't work. Put an ShowMessage
in the OnPostError handler to see what's happening. Before you set the
Filter property, examine the State property of the table to ensure that it's
not in dsInsert or dsEdit mode.

Hope this helps

Carl

Re:How to handle EDBEngine error key violation?


Quote
>s1:='Man*';
>  tNames.Filter:='(Company = '+QuotedStr(s1)+')';
>  tNames.Filtered:=true;
>an error is generated if no records match the filter.  The error is
>described "EDBEngine error.  Message Key violation"

That error is not the direct result of setting the filter.  Some other code in
your application is causing a record to post (probably a blank record) which is
generating this error.  You need to take a better look at your code.
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads