我使用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组件从另一个数据库切换?
发布于 2014-11-12 16:36:05
问题在于TZConnection.Protocol值大写化。将Protocol值从SQLite-3更改为sqlite-3。
https://stackoverflow.com/questions/26890563
复制相似问题