// 最好贴出代码with ADOQuery1 do begin try Close; Sql.Text := 'delete from tablename where ... ' ; ExecSql ; except On E : Exception do ShowMessage(e.Message) ; end ; end ;
但是我用EXECSQL执行时数据库没有修改,也就是每执行 我的代码 if adoquery1.active then adoquery1.close; adoquery1.sql.clear; adoquery1.sql.add('delete from table1 where ...'); adoquery1.active:=true;(用EXECSQL执行时数据库的记录没有被修改) showmessage('');
if adoquery1.active then adoquery1.close; adoquery1.sql.clear; adoquery1.sql.add('delete from table1 where ...'); //adoquery1.active:=true;(用EXECSQL执行时数据库的记录没有被修改) // 相当于 Open ; 更新用 ExecSql 方法 ; ADOQuery1.ExecSql ; showmessage('');
可以代参数执行with ADOQuery1 do begin try Close; Sql.Text := 'delete from tablename where id=:your_id ' ; Parameters.ParamByName['your_id'].value:='lile'; ExecSql ; except On E : Exception do ShowMessage(e.Message) ; end ; end ;用 adocommand 如下 with Aset_erp do begin close; commandtext:=''; commandtext:='select user_name,user_id,password,rights,department from fs_account where user_id='''+trim(ed_id.Text)+''' ' ; open; end;
begin
try
Close;
Sql.Text := 'delete from tablename where ... ' ;
ExecSql ;
except
On E : Exception do
ShowMessage(e.Message) ;
end ;
end ;
我的代码
if adoquery1.active then adoquery1.close;
adoquery1.sql.clear;
adoquery1.sql.add('delete from table1 where ...');
adoquery1.active:=true;(用EXECSQL执行时数据库的记录没有被修改)
showmessage('');
adoquery1.sql.clear;
adoquery1.sql.add('delete from table1 where ...');
//adoquery1.active:=true;(用EXECSQL执行时数据库的记录没有被修改) // 相当于 Open ; 更新用 ExecSql 方法 ;
ADOQuery1.ExecSql ;
showmessage('');
begin
try
Close;
Sql.Text := 'delete from tablename where id=:your_id ' ;
Parameters.ParamByName['your_id'].value:='lile';
ExecSql ;
except
On E : Exception do
ShowMessage(e.Message) ;
end ;
end ;用 adocommand 如下
with Aset_erp do
begin
close;
commandtext:='';
commandtext:='select user_name,user_id,password,rights,department from fs_account where user_id='''+trim(ed_id.Text)+''' ' ;
open;
end;