DELETE Statement in query

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jarlinx
Posts: 5
Joined: Wed 15 Dec 2010 00:19

DELETE Statement in query

Post by jarlinx » Wed 15 Dec 2010 00:27

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

AndreyZ

Post by AndreyZ » Wed 15 Dec 2010 15:46

Hello,

Please specify the database server you are working with.

jarlinx
Posts: 5
Joined: Wed 15 Dec 2010 00:19

Post by jarlinx » Wed 15 Dec 2010 21:40

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.

jarlinx
Posts: 5
Joined: Wed 15 Dec 2010 00:19

Post by jarlinx » Wed 15 Dec 2010 21:44

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;

AndreyZ

Post by AndreyZ » Thu 16 Dec 2010 07:59

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.

jarlinx
Posts: 5
Joined: Wed 15 Dec 2010 00:19

Post by jarlinx » Fri 17 Dec 2010 11:55

I send you a mail.

Thanks

AndreyZ

Post by AndreyZ » Fri 17 Dec 2010 15:19

We have answered you by e-mail.

jarlinx
Posts: 5
Joined: Wed 15 Dec 2010 00:19

Post by jarlinx » Sat 18 Dec 2010 00:34

Thank very much !

I have send You another mail.

AndreyZ

Post by AndreyZ » Mon 20 Dec 2010 09:13

We have answered you by e-mail.

Post Reply