首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

使用unidac连接sqlite3时 update、delete速度很慢,怎么解决

2013-11-29 
使用unidac连接sqlite3时 update、delete速度很慢,如何解决?代码如下:for i : Dgrid.SelectedRows.Count -

使用unidac连接sqlite3时 update、delete速度很慢,如何解决?
代码如下:


for i := Dgrid.SelectedRows.Count - 1 downto 0 do
    begin
      try
        tuniqurey1.GotoBookmark(pointer(Dgrid.SelectedRows.Items[i]));
        tuniqurey1.Edit;
        tuniqurey1.FieldValues['flag'] := 1;
      except
      end;
    end;
    try
      // tuniqurey1.Post;
      tuniqurey1.ApplyUpdates;
      tuniqurey1.Refresh;
    except
    end;


这样更改几条记录都需要花几秒钟,请教该如何解决。
[解决办法]
tuniqurey1.disablecontrols;

for i := Dgrid.SelectedRows.Count - 1 downto 0 do
    begin
      try
        tuniqurey1.GotoBookmark(pointer(Dgrid.SelectedRows.Items[i]));
        tuniqurey1.Edit;
        tuniqurey1.FieldValues['flag'] := 1;
      except
      end;
    end;
    try
      // tuniqurey1.Post;
      tuniqurey1.ApplyUpdates;
      tuniqurey1.Refresh;
    except
    end;

tuniqurey1.enablecontrols;
[解决办法]
先找出哪里慢。。。是循环慢还是 提交数据慢。。。在换写法来解决,循环用GotoBookmark 这个应该很慢吧,这个应该是定位到这条记录吧,不知道你的grid是DB的还是 不是DB的。
[解决办法]
SQLite不用事务性能超级低,一定要用事务。

热点排行