Author Topic: I am using lazarus 0.9.10 with FBLIB component under win2k,a  (Read 4861 times)


  • Guest
I am using lazarus 0.9.10 with FBLIB component under win2k,a
« on: April 05, 2006, 11:25:06 am »
I am using lazarus 0.9.10 with FBLIB component under win2k,and firebird1.5.3 database server was installed.
Using FBLIB Library,I can create a new firebird database in following code:
(The corresponing properties such as 'user' and 'password' were set at design time)
Code: [Select]
 TForm1 = class(TForm)
  FBLDatabase1: TFBLDatabase;
  procedure TForm1.FormCreate(Sender: TObject);
  DB : string;
    DB := 'd:\lazarus\dbprojects\test.fdb';

  Now I wonder that if I can do the same thing by using zeos component set?
  The reason I ask this is because that I would write a DB application to do things such as creating new database/table,maintaining the structure of tables,editing records in a dbgrid,etc.But there is no TTable component in the FBLIB Library.The zeos component set comes with a TZTable component,but I don't know how to create a new firebird database by using it.


  • Hero Member
  • *****
  • Posts: 537
RE: I am using lazarus 0.9.10 with FBLIB component under win
« Reply #1 on: April 05, 2006, 12:28:36 pm »
If you can create a database with ZEOS components I do not know. But ...
You can always use a TQuery component. With TQuery you can do the lot, display data, edit data, remove records. TTable is a relic left over from the good old Delphi1 and BDE days.
What's in a sig? Would my posting look less if it didnot have a sig? (Free after William S.) :)

:( Why cannot I upload my own Avatar? :(


  • Guest
RE: I am using lazarus 0.9.10 with FBLIB component under win
« Reply #2 on: April 07, 2006, 05:24:18 am »
I read these files:ZPlainInterbaseDriver.pas,ZPlainFirebird15.pas,
ZPlainloader.pas,and the document Apiguide.pdf
so I made a test application as following:

Code: [Select]
unit fbtest;

{$mode objfpc}{$H+}


  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
  Buttons, Menus, EditBtn, ComCtrls, DBCtrls, DBGrids, DB, sqldb,
  ZDataset, ZConnection, ZSqlProcessor, ZSqlMonitor, ZSequence,
  ZPlainFirebird15, ZPlainInterbaseDriver, windows;


  { TForm1 }

  TForm1 = class(TForm)
  BtnCreateNewDataBase : TButton;
  procedure BtnCreateNewDataBaseClick(Sender: TObject);

  Form1: TForm1;



procedure TForm1.BtnCreateNewDataBaseClick(Sender: TObject);
status_vector : PISC_STATUS;
db_handle : TISC_DB_HANDLE;
tran_handle : TISC_TR_HANDLE;
statement : string;
  statement := 'CREATE DATABASE ''C:\mydb\test.fdb'' PAGE_SIZE 4096 USER ''SYSDBA'' PASSWORD ''masterkey'';';
  isc_dsql_execute_immediate := Tisc_dsql_execute_immediate(GetProcAddress(LoadLibrary('C:\FireBird15\bin\fbclient.dll'),'isc_dsql_execute_immediate'));
  db_handle := nil;
  tran_handle := nil;

The application was compiled and can be run,but when I click on the BtnCreateNewDataBase,
there is a message 'Access violation.Press OK to ignore,press cancel to stop the program'.
(I look at the c:\mydb directory,the new database 'test.fdb' was created and its size is 584kb.)

on page 325 of the document Apiguide.pdf it says:
the 4th parameter of isc_dsql_execute_immediate(Length of the DSQL statement in bytes) should be set to 0 in C programs to
indicate a null-terminated string.

If I change it to Length(statement),the result is the same as above.


  • Administrator
  • Hero Member
  • *
  • Posts: 2496
RE: I am using lazarus 0.9.10 with FBLIB component under win
« Reply #3 on: April 07, 2006, 12:22:54 pm »
first, when loading libs, keep the handle, you need to unload them.

- does lib := LoadLibrary('C:\FireBird15\bin\fbclient.dll') return a valid handle ?
- does proc := GetProcAddress(lib,'isc_dsql_execute_immediate' ) return a valid adress ?
- does status_vector need to be initialized ?
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker