2

我使用 Zeoslib 组件与我的 SQLite 数据库文件进行交互。我在一个文件夹中有几个 SQLite 数据库文件。所以,我希望能够使用 Zeoslib 组件打开其中的任何一个。但是,它不会让我。它成功打开了第一个数据库,但之后我打开的任何数据库文件,都会出现访问冲突错误。对于我的生活,我根本无法弄清楚为什么。

这是我打开数据库文件的方法。

procedure TMainFrm.Open1Click(Sender: TObject);
var currdb:string;
begin
 OpenDlg.InitialDir := BaseDir;
 if OpenDlg.Execute = true then
 begin
      currdb := Extractfilename(OpenDlg.FileName);
      DataModule1.ZConnection1.Disconnect;
      DataModule1.ZConnection1.Protocol := 'SQLite-3';
      DataModule1.ZConnection1.Database :=baseDir + currdb;

      DataModule1.Query1.SQL.Clear;
      DataModule1.Query1.SQL.Add('SELECT * FROM MyTable'); // <<<<--- ZConnection1 is Query1 database connection.

      DataModule1.ZConnection1.Connect; // <<<<<-------Here is where I get ACCESS VIOLATION all the time.
      UpdateGrid; // <<<<<<<----- Here is where the Query is executed and the DBGrid is updated.
 end;
end;

我不知道这是为什么。这是否意味着我不能使用 Zeoslib 组件从另一个数据库切换?

4

1 回答 1

2

问题在于TZConnection.Protocol价值资本化。Protocol将值从更改SQLite-3sqlite-3

于 2014-11-12T16:36:05.377 回答