DELETE Statement in query
DELETE Statement in query
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
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
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.
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.
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.
- 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.