Recent

Author Topic: help on fblib: lazarus + firebird  (Read 11106 times)

AkiFoblesia

  • New member
  • *
  • Posts: 9
help on fblib: lazarus + firebird
« on: November 26, 2006, 02:20:35 am »
hi! i know how to create, query and update database using firebird, however i'm new on database connections using lazarus.

i want to try using lazarus + firebird (embedded) via fblib.

can someone please write what i should write in the code explorer and what i should enter in the object inspector in order to connect to an existing database?

an example would definitely help - i tried the documentation but there is not enough for the totally new to lazarus.

thanks  :wink:

bmt

  • New member
  • *
  • Posts: 9
RE: help on fblib: lazarus + firebird
« Reply #1 on: December 01, 2006, 04:55:10 pm »
Last week i 've done some tests about databases & lazarus in Windows. I didn't write any code in the code explorer but only using properties in the object inspector of Lazarus.
I have installed Lazarus 0.9.18_win32 + MySQL 5.0.27 + FireBird 2.0 + FBLib 0.85
----------------
method 1A: FireBird/InterBase (*.fdb) + Lazarus

IBConnection1 -> SQLTransaction1 -> SQLQuery1 -> DataSource1 -> DBGrid1

Result: It works very good inside IDE (Run F9). Scrolling in DBGrid1 is OK  :D
------------
method 1B: FireBird/InterBase (*.fdb) + Lazarus

FBLDatabase1 -> FBLTransaction1 -> FBLDataset1 -> DataSource1 -> DBGrid1

Result: Sometimes it works in IDE, if not then build it (Ctrl+F9) and run it outside IDE  :?: . Scrolling gives problem when use key arrow-up.  :(
---------------
method 2: mySQL database + Lazarus

MySQL50Connection1 -> SQLTransaction1 -> SQLQuery1 -> DataSource1 -> DBGrid1

Result: It only works outside IDE  :?: . Scrolling in DBGrid1 is OK  :D
==============

Now more details in Object inspector:

---1A---
IBConnection1: (Properties)
DatabaseName: .....\employee.fdb,   Dialect:3,  HostName: localhost,  KeepConnection: True,  Password: masterkey,  User: sysdba, Connected: True,  (+Transaction: SQLTransaction1)

SQLTransaction1: (Properties)
+Database: IBConnection1,  Active: True

SQLQuery1: (Properties)
+Database: IBConnection1,  ParseSQL: True,  (ReadOnly: True),  SQL: [...] select * from customer,  StatementType: stSelect,  +Transaction: SQLTransaction1,  Active: True

Datasource1: (Properties)
+Dataset: SQLQuery1
 
DBGrid1: (Properties)
+DataSource: Datasource1
 
---1B---
FBLDatabase1: (Properties)
DBFile: .....\employee.fdb,   Host: localhost,  Password: masterkey,  SQLDialect: 3,  User: sysdba, Connected: True

FBLTransaction1: (Properties)
+Database: FBLDatabase1

FBLDataset1: (Properties)
+Transaction: FBLTransaction1,  AutoStartTransaction: True,  Active: True

Datasource1: (Properties)
+Dataset: FDLDataset1
 
DBGrid1: (Properties)
+DataSource: Datasource1
 
---2---
MySQL50Connection1: (Properties)
DBFile: .....\testSQLDB,   HostName: localhost,  KeepConnection: True, LoginPrompt: True/False, Password: root,  User: root, Connected: True,  (+Transaction: SQLTransaction1)

SQLTransaction1: (Properties)
+Database: MySQL50Connection1,  Active: True

SQLQuery1: (Properties)
+Database: MySQL50Connection1,  ParseSQL: True,  (ReadOnly: True),  SQL: [...] select * from any_table,  StatementType: stSelect,  +Transaction: SQLTransaction1,  Active: True

Datasource1: (Properties)
+Dataset: SQLQuery1
 
DBGrid1: (Properties)
+DataSource: Datasource1
========================

(PS. In Delphi, in order to use DBGrid we must use DatasetProvider & ClientDataset before DataSource. But in Lazarus we don't need them. Why ?)

Best regards

jesusr

  • Sr. Member
  • ****
  • Posts: 484
RE: help on fblib: lazarus + firebird
« Reply #2 on: December 02, 2006, 07:34:05 am »
Are you using fblib 0.85?, I just went to their web site and they have marked clearly that FBLDataset is Readonly, Unidirectional. This means that you will have limited browsing capabilities, it can only browse forward in the grid.

Saverio

  • New member
  • *
  • Posts: 8
help on fblib: lazarus + firebird
« Reply #3 on: December 04, 2006, 01:14:43 am »
Well by default the FBLDataset is ReadOnly and Unidirectional but if you declare:
 
FBLDataset.SQL.Text:= 'Select * from employee order by First_Name';
FBLDataset.Open;
FBLDataset.IsUniDirectional:= False;

you can browse any way.[/b]

jesusr

  • Sr. Member
  • ****
  • Posts: 484
help on fblib: lazarus + firebird
« Reply #4 on: December 04, 2006, 01:56:21 am »
It's nice to know that fblib is not only unidirectional, if it's so, bmt could try to test turning off this property and try again, if problem persist, bmt please submit a bug report using bug tracker, and include as much details a you can (a test project to would be great).

bmt

  • New member
  • *
  • Posts: 9
help on fblib: lazarus + firebird
« Reply #5 on: December 04, 2006, 12:25:05 pm »
Thank you Saverio & Jesusr. It works now in IDE, scrolling is no more trouble! Nice!
==========
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
  FBLDatabase, FBLTransaction, FBLDsql, DB, DBGrids, FBLDataset;

type

  { TForm1 }

  TForm1 = class(TForm)
    Datasource1: TDatasource;
    DBGrid1: TDBGrid;
    FBLDatabase1: TFBLDatabase;
    FBLDataset1: TFBLDataset;
    FBLTransaction1: TFBLTransaction;
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
begin
  FBLDataset1.IsUniDirectional:= False;
end;

initialization
  {$I unit1.lrs}

end.
==========
(I still use Lazarus 0.9.18 because of the working scrollbars for Form)

I think the methods of IBConnenction & MySQLConnection are also nice if they also work in IDE !

 

TinyPortal © 2005-2018