Recent

Author Topic: SQLite3Connection.databasename make exception "external SIGSEGV"  (Read 2415 times)

vs99

  • Newbie
  • Posts: 4
SQLite3Connection.databasename make exception "external SIGSEGV"
« on: November 20, 2014, 09:05:23 pm »
Hello,

I have problem with copile project on Win with SQLite.

SQLite3Connection.databasename:='test.db'; - make exception "external SIGSEGV".

If I have the same code in MainForm, all do normally. But I move code to second unit and from Unit1 call any procedures and functions with SQLite3connection, appears exception.  :(

Anyone have an idea?

Thanks
Vladimir

kapibara

  • Hero Member
  • *****
  • Posts: 518
Re: SQLite3Connection.databasename make exception "external SIGSEGV"
« Reply #1 on: November 20, 2014, 10:58:12 pm »
Vladimir,

"External SIGSEGV" usually means that the object you are trying to access is not created yet. So check where you create SQLite3Connection. (what form and when)

DataModules are good places to keep these things and also separate database code from the rest of the program. I usually put my Connection (named Conn) and Transaction (named TX) in a DataModule (named DM) and call:

Code: [Select]
DM.Conn.DatabaseName:= 'somedb';
If you do that, I suggest go to project options -> Forms and move the datamodule up in the creation-list so it is created first of all. Then you can access all the datamodule objects from any form that has your datamodule in its uses clause.
Lazarus trunk / fpc 3.0.4 / Debian 10 - 64 bit

tudi_x

  • Hero Member
  • *****
  • Posts: 532
Re: SQLite3Connection.databasename make exception "external SIGSEGV"
« Reply #2 on: November 20, 2014, 11:00:37 pm »
Hi,
Had the same issue.
Switched to Zeos components and no issue.
Example below:

Code: [Select]
constructor Query.Create(TheDBFile, TheSQLiteDLL : string);
    begin
      db_filename := TheDBFile;
      db_driver   := TheSQLiteDLL;
    end;


    function Query.RunQSQLite(AQuery : string) : boolean;
    begin
        ZConnSQLite                := TZConnection.Create(nil);
        ZConnSQLite.Protocol   := 'sqlite-3';
        ZConnSQLite.Database  := db_filename;
        ZConnSQLite.LibraryLocation:= db_driver;
        ZConnSQLite.Connect;

        Result := ZConnSQLite.ExecuteDirect(AQuery);
        ZConnSQLite.CleanupInstance;
        ZConnSQLite.Disconnect;
        ZConnSQLite.FreeInstance;
    end;
Lazarus 2.0.2 64b on Debian LXDE 10

vs99

  • Newbie
  • Posts: 4
Re: SQLite3Connection.databasename make exception "external SIGSEGV"
« Reply #3 on: November 21, 2014, 12:51:42 am »
Thansk for all!  :)

I went through by Kapibara. It worked.

Info for others - after moving "DB Form" over "Main form" in Project options you must create action "OnShow" on "DBForm" and put in to DBForm.visible:=false;
Otherwise DBForm wil show on top application.  :)