marioway
asked on
TQuery locate problem
Hi, I have another problem
I run IBQuery6 -> select * from Bedrijsvorm
then
procedure TAdministratie.ComboBox1Ex it(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('BEDRIJFSV ORMEN', A, [])then begin
IBQuery5.Close;
IBQuery5.SQL.Clear;
IBQuery5.SQL.Add('Insert INTO BEDRIJFSVORM (BEDRIJFSVORMEN) Values(:A)');
IBQuery5.Params[0].AsStrin g:= 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
I run IBQuery6 -> select * from Bedrijsvorm
then
procedure TAdministratie.ComboBox1Ex
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('BEDRIJFSV
IBQuery5.Close;
IBQuery5.SQL.Clear;
IBQuery5.SQL.Add('Insert INTO BEDRIJFSVORM (BEDRIJFSVORMEN) Values(:A)');
IBQuery5.Params[0].AsStrin
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Geert, thx a lot; what would I do without you guys ... I'm creating a client/server version of my stand-alone program from scratch. Not so easy, but I'm learning fast. I'm gone a have a look at that rdb$databse thing ; seems very important ...
Mario
Mario
I'd use
if not IBQuery2.Locate('BEDRIJFSV
It's a bit difficult find a right answer without knowing the structure of the table when you're trying to insert that value