Recent

Author Topic: Using SQlite in Lazarus  (Read 11611 times)

hulky

  • Guest
Using SQlite in Lazarus
« on: April 14, 2005, 08:42:43 pm »
I am trying to use an sqlite database in my lazarus program using the sqlitedb unit (as included with lazarus). When I compile it straight (as fpc-programm) this works fine but as soon as I try to compile it as a lazarus windows programm I get the following error:

sqlitedb.pas(341,55) Error: Incompatible type for arg no. 3: ....... etc.

Can anybody tell me how to solve this?

Regards,

Wim

Anonymous

  • Guest
RE: Using SQlite in Lazarus
« Reply #1 on: October 03, 2005, 11:42:15 am »
I got the same thing with the lastest version 0.9.8 beta !

Someone can say how to solve that ?


Thankx

E.Jourde

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2512
RE: Using SQlite in Lazarus
« Reply #2 on: October 03, 2005, 02:32:08 pm »
what is on line: sqlitedb.pas(341,55) ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Anonymous

  • Guest
RE: Using SQlite in Lazarus
« Reply #3 on: October 03, 2005, 03:34:54 pm »
ok i don't uses the TSQliteDataset compoment, but the test.pp program (wich use sqlite and sqlitedb)

there is this :
    fError := SQLite_Exec(fSQLite, Psql, @ExecCallback, Self, @fPMsg);

who don't want compile with incompatible type of arg no. 3

Tanks

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2512
RE: Using SQlite in Lazarus
« Reply #4 on: October 04, 2005, 01:59:24 pm »
OK, what does SQLite_Exec expect for type of parameter 3
and what is the declaration of ExecCallback
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

LuizAmérico

  • Sr. Member
  • ****
  • Posts: 458
Using SQlite in Lazarus
« Reply #5 on: October 12, 2005, 11:22:22 pm »
Lazarus only ships with the sqlite TDataset descendant (TSqliteDataset that resides in sqliteds.pas). SqliteDB unit is not mantained/updated/tested AFAIK, so use it at your own risk.

Here's a patch to compile sqlitedb.pas (I did not test it with data):



Index: sqlitedb.pas
===================================================================
--- sqlitedb.pas   (revisão 726)
+++ sqlitedb.pas   (cópia de trabalho)
@@ -185,14 +185,14 @@
   end;
 end;
 
-function ExecCallback(Sender: TObject; Columns: Integer; ColumnValues: Pointer; ColumnNames: Pointer): integer; cdecl;
+function ExecCallback(Sender: Pointer; Columns: Integer; ColumnValues: PPChar; ColumnNames: PPChar): integer; cdecl;
 var
   PVal, PName: ^PChar;
   n: integer;
   sVal, sName: String;
 begin
   Result := 0;
-  with Sender as TSQLite do
+  with TSQLite(Sender) do
   begin
     if (Assigned(fOnData) or Assigned(fTable)) then
     begin
@@ -213,7 +213,7 @@
       sVal := fLstVal.CommaText;
       sName := fLstName.CommaText;
       if Assigned(fOnData) then
-        fOnData(Sender, Columns, sName, sVal);
+        fOnData(TObject(Sender), Columns, sName, sVal);
       if Assigned(fTable) then
       begin
         if fTable.Count = 0 then

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Using SQlite in Lazarus
« Reply #6 on: October 12, 2005, 11:44:52 pm »
Maybe this patch should be sent to the FPC? The unit may be old, but it may still be of some use.

LuizAmérico

  • Sr. Member
  • ****
  • Posts: 458
Using SQlite in Lazarus
« Reply #7 on: October 13, 2005, 12:15:21 am »
As i said i did not tested the unit so maybe it's not working correctly although compiling. Anyway anyone can look at the code, test it, modify (if necessary) and send the changes to fpc (It's open source ;-))

For myself, i dont have the necessary time/interest in doing so, since i don't see advantages of using it over TSqliteDataset, which i maintain

BTW: Where are you from?

Luiz

 

TinyPortal © 2005-2018