Page 1 of 1

SQLite3 Connect Error

Posted: 02.04.2010, 08:50
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

Posted: 03.04.2010, 20:40
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

Posted: 04.04.2010, 08:48
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;

Posted: 13.04.2010, 21:47
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

Posted: 14.04.2010, 08:59
by KenR
Mark,

Yes, that works fine thanks.

Ken