我是用BDE的Query组件来刷新数据库的(Paradox).
Query1.close;
Query1.sql.clear;
Query1.sql.add('update 数据库名 set 单位=*** where ID=***');
Query1.ExecSQL;
但是会偶尔丢失数据,丢的是最近的数据,不知道为什么会这样。如果用Table可以用Table1.FlushBuffers来写,不知道Query还要用什么语句来写不会丢失语句?

解决方案 »

  1.   

    Query1.close;
    Query1.sql.clear;
    Query1.sql.add('update 数据库名 set 单位=*** where ID=***');
    Query1.sql.add(‘select * from 数据库名’);
    query1.open;
    query1.close;
    query1.open;将代码改成上面的样子应该可以,
    理由我也不太清楚,好像是跟windows的处理数据方式有关。
      

  2.   

    Query1.close;
    Query1.sql.clear;
    Query1.sql.add('update 数据库名 set 单位=*** where ID=***');
    Query1.ExecSQL;   //到这里只是更新数据
    // 这样刷新数据
    Query1.Close;
    Query1.SQL.Clear;
    Query1.SQL.Add('SELECT * FROM 数据库名');
    Query1.Open;
      

  3.   

    楼上的这是什么理由呀?
    不是吧,用QUERY还会数据丢失?
      

  4.   

    原因就在这里了吧,你没有调用 CommitUpdates提交你的修改了
    Query1.close;
    Query1.sql.clear;
    Query1.sql.add('update 数据库名 set 单位=*** where ID=***');
    Query1.ExecSQL;
    Query1.CommitUpdates;
    //我想这样总不会再有问题了吧Clears the cached updates buffer.procedure CommitUpdates;DescriptionCall CommitUpdates to clear the cached updates buffer after both a successful call to ApplyUpdates and a database component抯 Commit method. Clearing the cache after applying updates ensures that the cache is empty except for records that could not be processed and were skipped by the OnUpdateRecord or OnUpdateError event handlers. An application can attempt to modify the records still in the cache.Record modifications made after a call to CommitUpdates repopulate the cached update buffer and require a subsequent call to ApplyUpdates to move them to the database.Note: Applications that use a database component抯 ApplyUpdates method to apply and commit pending updates for all datasets associated with the database component do not need to call CommitUpdates.
      

  5.   

    不是 query的问题 
    请找其他原因
      

  6.   

    我个觉得也不是。
    用SQL直接更新数据库应该不会出现这种问题。
    倒是用table有可能出现。
    总之BDE不好
      

  7.   

    Query1.ExecSQL是不是立刻就执行SQL的语句?立即刷新数据库,而不是表面的刷新了数据,真正的数据库并没有刷新?它会不会偶尔这样?请大家帮忙!
      

  8.   

    ”数据丢失“?在什么地方丢失了什么数据?我都没搞懂。
    Query1.CommitUpdates;没有必要,因为Update直接在数据库里执行。
    并非BDE不好,虽然总的来说使用麻烦一些。————————————————————————————————————
    宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
    ————————————————————————————————————
      

  9.   

    应该不是Query的原因吧,你查一下,你是不是在程序里不记得对数据进行保存了?
      

  10.   

    Query1.close;
    Query1.sql.clear;
    Query1.sql.add('update 数据库名 set 单位=*** where ID=***');
    Query1.ExecSQL;关键是这最后一句!!!!!
    Query1.ExecSQL;    =======》》   Query1.open;
    但是原因小弟就不知道了。
    还有,看看你的数据库中有什么问题么?
      

  11.   

    因为你用的是 update 嘛,这不是插入记录,而是修改记录。
    如果要插入记录,用 insert
    很可能是操作人员把一条空记录 update 了有数据的记录,当然数据丢失啦