troubleshooting Question

TQuery locate problem

Avatar of marioway
marioway asked on
DatabasesDelphi
3 Comments1 Solution440 ViewsLast Modified:
Hi, I have another problem

I run IBQuery6 -> select * from Bedrijsvorm

then

procedure TAdministratie.ComboBox1Exit(Sender: TObject);
var A: string;
begin
with Datamodule1 do begin
 if Trim(ComboBox1.Text) = '' then begin
  ShowMessage('Veld bedrijfsvorm MOET worden ingevuld !');
  ComboBox1.SetFocus;
  Exit;
 end
 else
  begin
   A:= Trim(ComboBox1.Text);
   if not IBQuery2.Locate('BEDRIJFSVORMEN', A, [])then begin
      IBQuery5.Close;
      IBQuery5.SQL.Clear;
      IBQuery5.SQL.Add('Insert INTO BEDRIJFSVORM (BEDRIJFSVORMEN) Values(:A)');
       IBQuery5.Params[0].AsString:= A ;
      IBQuery5.ExecSQL;
   end
    else
     begin
      Exit;
     end;
  end;
end;
end;

When I run the program, and exit the combobox, a locate is performed inside IBQuery6

When it does not find the value, run IBQuery5 to insert the value into bedrijfsvorm, else
Exit . The result is that I get an error (primary key violation), instead of exiting without trying to insert...

problem ?

thx
Mario
ASKER CERTIFIED SOLUTION
Geert G
Oracle dba
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros