读书人

帮帮小弟,odac方面的有关问题

发布时间: 2012-03-01 10:25:47 作者: rapoo

帮帮小弟,odac方面的问题
一条Delete语句,在Oracle里很快就运行完了,在程序里为什么ExecSQL半天也没响应?
可能是什么原因?

SmartQuery1.Session := OraSession1;
with SmartQuery1 do
begin
SQL.Clear;
SQL.Add('delete from table where name='''+ DBLookupListBox1.KeyValue +''' and ID= '''+ Trim(ID.Text)+'''');
SQL.Text;
ExecSQL;
end;


[解决办法]
SmartQuery1.Session := OraSession1;
with SmartQuery1 do
begin
Close;
SQL.text := 'delete from table where name='''+ DBLookupListBox1.KeyValue +''' and ID= '''+ Trim(ID.Text)+'''';
ExecSQL;
end;

这样执行试试

SmartQuery1.Session := OraSession1;
with SmartQuery1 do
begin
Close;
SQL.text := 'delete from table where name=:name and id=:ID';
ParamByName('name').value := DBLookupListBox1.KeyValue;
ParamByName('ID').value := Trim(ID.Text);
ExecSQL;
end;

读书人网 >.NET

热点推荐