sql查询得到的结果是只读,要修改需通过与UpdateSQL一同进行,
http://www.delphibbs.com/delphibbs/dispq.asp?lid=625571
看看这个例子 ,(运行通过) t_debug (id,new) ,t_debug2(id,old)
query1.SQL.text:='select t_debug.id as id,new,old from t_debug left join t_debug2 on t_debug.id=t_debug2.id';
updatesql1.InsertSQL.add('insert into t_debug(id,new) values
id,:new)');
updatesql1.DeleteSQL.add('delete from t_debug where id=:id and new=:new');
updatesql1.ModifySQL.Add('update t_debug set id=:id,new=:new where id=
ld_id and new=
ld_new');
query1.CachedUpdates:=true;
query1.UpdateObject:=updatesql1;
query1.Open;
query1.Edit;
query1.FieldByName('id').AsString:=edit1.Text;
query1.FieldByName('new').AsString := edit2.Text;
query1.Database.StartTransaction;
try
query1.ApplyUpdates;
query1.Database.Commit;
except
showmessage('error');
query1.Database.Rollback;
end;