gpt4 book ai didi

database - Zeoslib 不允许切换数据库?

转载 作者:搜寻专家 更新时间:2023-10-30 20:27:12 25 4
gpt4 key购买 nike

我使用 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 组件从另一个数据库切换数据库?

最佳答案

问题出在 TZConnection.Protocol 值大写中。将 Protocol 值从 SQLite-3 更改为 sqlite-3 .

关于database - Zeoslib 不允许切换数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26890563/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com