Page 1 of 1
DELETE Statement in query
Posted: Wed 15 Dec 2010 00:27
by jarlinx
Hello
I have problem with TUniQuery components. When I run this code:
procedure TForm1.btDeleteClick(Sender: TObject);
var
q: TUniQuery;
begin
q := TUniQuery.Create(nil);
q.Connection := UniConnection1;
q.SQL.Text := 'DELETE FROM EWIDENCJA WHERE ID = :OLD_ID';
q.Params[0].Value := 6;
q.ExecSQL;
q.Close;
q.Free;
end;
then application stopped on line with "q.ExecSQL".
What do I bad ?
(sorry for english)
thx
Posted: Wed 15 Dec 2010 15:46
by AndreyZ
Hello,
Please specify the database server you are working with.
Posted: Wed 15 Dec 2010 21:40
by jarlinx
Hello
Thanks for answer.
I use SQL Server 2005 Express Edition.
I have a View with 2 tables in dbgrid.
Property UniQuery.SQL is "SELECT * FROM V_PERSON ORDER BY NUMBER"
I'm not editing this data on grid. I'm editing from code.
For Updating I write code:
procedure TForm1.btUpdateClick(Sender: TObject);
var
uq: TUniQuery;
begin
uq := TUniQuery.Create(nil);
uq.Connection := UniConnection1;
uq.SQL.Text := 'UPDATE PERSON SET NAME = :NAME WHERE ID = :ID';
uq.Params[0].Value := 'BROWN';
uq.Params[1].Value := UniQuery1ID.AsInteger;
uq.ExecSQL;
uq.Close;
uq.Free;
end;
Value "UniQueryID.AsInteger" for Params[1] is a field ID value from
selected record in dbgrid.
This code working fine.
To Delete I write code:
procedure TForm1.btDeleteClick(Sender: TObject);
var
uq: TUniQuery;
begin
uq := TUniQuery.Create(nil);
uq.Connection := UniConnection1;
uq.SQLDelete.Text := 'DELETE FROM PERSON WHERE ID = :ID';
uq.Params[0].Value := UniQuery1ID.AsInteger;
uq.ExecSQL;
uq.Close;
uq.Free;
end;
In this code in line uq.ExecSQL program stopped.
Greetings.
Posted: Wed 15 Dec 2010 21:44
by jarlinx
sorry Delete code is:
procedure TForm1.btDeleteClick(Sender: TObject);
var
uq: TUniQuery;
begin
uq := TUniQuery.Create(nil);
uq.Connection := UniConnection1;
uq.SQL.Text := 'DELETE FROM PERSON WHERE ID = :ID';
uq.Params[0].Value := UniQuery1ID.AsInteger;
uq.ExecSQL;
uq.Close;
uq.Free;
end;
Posted: Thu 16 Dec 2010 07:59
by AndreyZ
I could not reproduce the problem. Please supply me the following information:
- the exact version of UniDAC. You can see it in the About sheet of TUniConnection Editor;
- the exact version of your IDE.
Also you can send me a complete small sample to andreyz*devart*com to demonstrate the problem, including a script to create a table.
Posted: Fri 17 Dec 2010 11:55
by jarlinx
I send you a mail.
Thanks
Posted: Fri 17 Dec 2010 15:19
by AndreyZ
We have answered you by e-mail.
Posted: Sat 18 Dec 2010 00:34
by jarlinx
Thank very much !
I have send You another mail.
Posted: Mon 20 Dec 2010 09:13
by AndreyZ
We have answered you by e-mail.