Zeoslib won't allow switching database?

247 views Asked by At

I use Zeoslib components to interact with my SQLite database file. I have several SQLite database files in a folder. So, I want to be able to open any one of them using Zeoslib component. However, it won't let me. It opens the first database successfully but any database file I open after that, I get access violation error. For the life of me, I simply can't figure it out WHY.

Here is how I open database file.

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;

I don't know why this is. Is this mean I can't switch database from another using Zeoslib component?

1

There are 1 answers

0
ThN On BEST ANSWER

The problem is in the TZConnection.Protocol value capitalization. Change the Protocol value from SQLite-3 to sqlite-3.