SQLite3 Connect Error

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

Locked
KenR
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 02.04.2010, 08:37

SQLite3 Connect Error

Post by KenR »

When I try to connect to a database named, for example C:\Test\André\DB.db I get the error Library routine called out of sequence. With C:\Test\Andre\DB.db it is fine.

Ken
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Don't know what compilerer you're working with. Seems like a databasename encoding problem.
A little debugging of TZSQLiteConnection.Open may show where the bad conversion occurs.

Mark
Image
KenR
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 02.04.2010, 08:37

Post by KenR »

I'm using Delphi 2010. I managed to fix this by changing the code as follows:

function TZSQLiteBaseDriver.Open(const filename: PAnsiChar; mode: Integer;
var errmsg: PAnsiChar): Psqlite;
var
Result0: Psqlite;
Version: string;
FileNameString: String;
begin
// Result0:= nil;
// Version := LibVersion;
// FileNameString := filename;
// if (Version > '3.2.5') then
// SQLite_API.sqlite_open(PAnsiChar(AnsiToUTF8(FileNameString)), Result0)
// else
SQLite_API.sqlite_open(filename, Result0);
Result := Result0;
end;
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Does this version work on your system?

Code: Select all

function TZSQLiteBaseDriver.Open(const filename: PAnsiChar; mode: Integer;
  var errmsg: PAnsiChar): Psqlite;
var
  Result0: Psqlite;
{$IFNDEF DELPHI12_UP}
  Version: string;
  FileNameString: String;
{$ENDIF}
begin
  Result0:= nil;
{$IFDEF DELPHI12_UP}
    SQLite_API.sqlite_open(filename, Result0);
{$ELSE}
  Version := LibVersion;
  FileNameString := filename;
  if (Version > '3.2.5') then
    SQLite_API.sqlite_open(PAnsiChar(AnsiToUTF8(FileNameString)), Result0)
  else
    SQLite_API.sqlite_open(filename, Result0);
{$ENDIF}
  Result := Result0;
end;
That one is safe for all compilers I use and should do exactly what your patch does on D2010, I believe.

Looking at the code in zdbcsqlite.pas and ZPlainSqLiteDriver.pas I think somebody could find a more elegant solution for the 'Open' code. Please, feel free to do suggestions.

Committed this version to SVN testing branch. (rev. 801)
Mark
Image
KenR
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 02.04.2010, 08:37

Post by KenR »

Mark,

Yes, that works fine thanks.

Ken
Locked