在删除功能里,在Delete一条数据前,我想先把数据insert到一张备份表里(数据在A表,备份表是B,A和B数据结构一样),然后再Delete,请问怎么动态的得到要插入的数据呢?

解决方案 »

  1.   

    就是说
    with DataModule1.ADOQueryPrjmaintain do
      begin
        SQL.Add('insert??')//怎么得到插入的数据呢    delete;
        DrawAdvStringGrid;
      end;
      

  2.   

    这个好办,首先用sql获取这个记录,select * from table where XX=XX,然后
     insert;
     fieldByName(xxx).asstring:=adotable.fieldByName('xxx').asstring;
    post;
    这样就插入了,接着就可以删除了!
      

  3.   

    with DataModule1.ADOQueryPrjmaintain do
      begin
        sql.clear;
        SQL.Add( 'insert into b select * from a where xx=xx ')//怎么得到插入的数据呢    delete;
        ExecSQL;
        sql.clear;
        sql.add( 'delete from a where xx=xx' );
        ExecSQL;
        DrawAdvStringGrid;
      end
      

  4.   

    with DataModule1.ADOQueryPrjmaintain do
      begin
        sql.clear;
        SQL.Add(  'insert into b select * from a where xx=xx  ')//怎么得到插入的数据呢    delete;
        ExecSQL;
        sql.clear;
        sql.add(  'delete from a where xx=xx ' );
        ExecSQL;
        DrawAdvStringGrid;
      end
      

  5.   

    多谢楼上的各位了,我的意思是我也不能确定这个要删除的纪录,我做的功能是在界面上点击查询后显示得到的一个结果集,现在要求可以对这个结果集里的数据进行删除,就是在任意一条数据上点击右键有一个删除功能,然后回到开始的问题,“在Delete一条数据前,我想先把数据insert到一张备份表里(数据在A表,备份表是B,A和B数据结构一样),然后再Delete,请问怎么动态的得到这个要插入的数据呢?”
      

  6.   

    这个和你最开始的意思一样啊,首先查询出数据集,然后删除,删除的同时首先备份到另外一张表中!
    在右键菜单某个的onclick事件中:
    // 首先备份
        ADOTable.Open;//ADOTable链接的是A表
       with ADOTable do
       begin
         Insert;
         FieldByName('XXX').asString:=BTable.FieldByName('xxx').asString;
         ....
         Post;
       end;
    //这样就给A表中要删除的记录保存到B表中了
    //然后删除A表中的记录
    //这里直接使用sql语句
    with ADOTable do 
    begin
     close;
     sql.text:='delete from A where XXX='+FieldByName('xxx').asstring;
     ExeSql;
    end;