How to create FireBird database from Lazarus lazarus / 16-Databases ---------------------------------------------------------------------- motaz · 2009-12-04 08:51 I need to create a new database from Lazarus application, the same like what I do using ISQL. Thanks ---------------------------------------------------------------------- clauslack · 2009-12-04 12:43 In SQLDB, there is IBConnection1.CreateDb (Before fill user, password, etc) I don't test this (I always use flamerobin) Regards. ---------------------------------------------------------------------- SteveF · 2009-12-04 21:52 Clauslack, Where can I find documentation of the methods, properties, etc. for these controls?  Both what is actually available and the parameters needed for proper use? Thanks, Steve ---------------------------------------------------------------------- clauslack · 2009-12-05 01:06 QuoteWhere can I find documentation I don't know, It is similar to TIBDatabase from Delphi. You can check the source code from sqldb too. I test this simple example and work fine. - Put an IBConnection1 in the form Code: [Select]procedure TForm1.Button1Click(Sender:TObject); begin IBConnection1.DatabaseName:='localhost:c:\prueba.fdb'; IBConnection1.UserName:='sysdba'; IBConnection1.Password:='masterkey'; IBConnection1.CreateDB; end; Tested with Lazarus 0.9.29 fpc 2.3.1, under Windows XP SP3 and Firebird SQL 2.1.3 - DatabaseAccess = Full in firebird.conf (you can use alias too). Firebird 2.1.3 has this defaults Database file ODS Version 11.1 Page size 4096 Page buffers 2048 Read only false Dialect 3 Default character set NONE Sweep interval 20000 Forced writes ON For assign Charset(UTF8) you need fpc 2.3.1 svn>= 13386, see http://bugs.freepascal.org/view.php?id=13835 Regards ---------------------------------------------------------------------- motaz · 2009-12-05 07:26 Thanks it works ---------------------------------------------------------------------- asdf · 2010-10-20 12:06 If I put the IBConnection1 into DataModule1, how should I refer Datamodule1 in this form? ---------------------------------------------------------------------- xenblaise · 2010-10-20 13:06 Your lazarus project [project1.lpr] Quoteprogram project1; {$mode objfpc}{$H+} uses   {$IFDEF UNIX}{$IFDEF UseCThreads}   cthreads,   {$ENDIF}{$ENDIF}   Interfaces, // this includes the LCL widgetset   Forms, Unit1, LResources, SQLDBLaz, Unit2   { you can add units after this }; {$IFDEF WINDOWS}{$R project1.rc}{$ENDIF} begin   {$I project1.lrs}   Application.Initialize;   Application.CreateForm(TForm1, Form1); //Application.CreateForm(TDataModule1, DataModule1);   Application.Run; end. Your Datamodule [unit2] Quoteunit Unit2; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, IBConnection, sqldb, db, FileUtil, LResources, Forms,   Controls, Dialogs; type   { TDataModule1 }   TDataModule1 = class(TDataModule)     Datasource1: TDatasource;     IBConnection1: TIBConnection;     SQLQuery1: TSQLQuery;     SQLTransaction1: TSQLTransaction;   private     { private declarations }   public     { public declarations }   end; implementation initialization   {$I unit2.lrs} end. Your form1 [unit1] Quoteunit Unit1; {$mode objfpc}{$H+} interface uses Unit2,   Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,   StdCtrls; type   { TForm1 }   TForm1 = class(TForm)     Button1: TButton;     procedure Button1Click(Sender: TObject);   private     { private declarations }     //YOUR DATAMODULE     MyMod: TDataModule1;   public     { public declarations }   end; var   Form1: TForm1; implementation { TForm1 } procedure TForm1.Button1Click(Sender: TObject); begin         MyMod.IBConnection1.DatabaseName:='localhost:c:\prueba.fdb';    MyMod.IBConnection1.UserName:='sysdba';    MyMod.IBConnection1.Password:='masterkey';         MyMod.SQLTransaction1.DataBase := MyMod.IBConnection1;    MyMod.IBConnection1.Transaction := MyMod.SQLTransaction1;         MyMod.SQLQuery1.DataBase := MyMod.IBConnection1;         MyMod.SQLQuery1.Transaction := MyMod.SQLTransaction1;         MyMod.SQLQuery1.SQL.Text := 'select * from yourtable';         MyMod.SQLQuery1.Open; end; initialization   {$I unit1.lrs} end. ---------------------------------------------------------------------- asdf · 2010-10-20 14:05 In DataModule I have: var   DataModule1: TDataModule1; implementation    Do I have to delete "DataModule1: TDataModule1;" ? ---------------------------------------------------------------------- asdf · 2010-10-20 15:07 Got error messase at: MyMod: TDataModule1; Identifier not found " TDataModule1 " ---------------------------------------------------------------------- xenblaise · 2010-10-20 23:08 QuoteGot error messase at: MyMod: TDataModule1; Identifier not found " TDataModule1 " uses Unit2,   Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,   StdCtrls; ---------------------------------------------------------------------- xenblaise · 2010-10-20 23:10 QuoteDo I have to delete "DataModule1: TDataModule1;" ?  You dont need to, so you would not delete or comment //Application.CreateForm(TDataModule1, DataModule1); ---------------------------------------------------------------------- xenblaise · 2010-10-20 23:20 rsdb := TSQLQuery.Create(nil); Quotewhy use datamodules while you can directly call them just like in vb6 cndb := TODBCConnection.Create(nil); stran := TSQLTransaction.Create(nil); stran.DataBase := cndb; stran.Action := caCommit; stran.Active := True; cndb.Transaction := stran; cndb.Open; rsdb.DataBase := cndb; rsdb.SQL.Text := 'SELECT * FROM Table1'; rsdb.Open; Quotemy another sample   TDBClass = class   private     // a data set to mantain all templates of database     dsQuery: TSQLQuery;     // the connection object     mycon: TMYSQL40Connection;     // SQL Transaction     SQLTransact: TSQLTransaction;   public     function openDB(): boolean;     procedure closeDB();     procedure clearDB();   end; implementation ... ... ... //TdbClass Usage // Open connection function TDBClass.openDB(): boolean; begin   try         dsQuery := TSQLQuery.Create(nil);         mycon := TMySQL40Connection.Create(nil);         SQLTransact := TSQLTransaction.Create(nil);         mycon.UserName := 'root';         mycon.HostName := 'localhost';         mycon.port := 3306;         mycon.DatabaseName := 'XXX';         SQLTransact.DataBase := mycon;         SQLTransact.Action := caCommit;         SQLTransact.Active := True;         dsQuery.DataBase := mycon;         mycon.Transaction := SQLTransact;         mycon.Open;        openDB := true;   except         openDB := false;   end; end; ---------------------------------------------------------------------- xenblaise · 2010-10-23 09:43 QuoteWHAT SHOULD I DELETE MORE TO MAKE IT FIT? Quoteprocedure TForm1.Button1Click(Sender: TObject); begin   rsdb := TSQLQuery.Create(nil);   cndb := TIBConnection.Create(nil);   trdb := TSQLTransaction.Create(nil);   cndb.DatabaseName:= 'c:\test005.fdb';   cndb.UserName:= 'sysdba';   cndb.Password:= 'masterkey';   cndb.CreateDB;   trdb.DataBase := cndb;   trdb.Action := caCommit;   trdb.Active := True;   rsdb.database := cndb;   rsdb.sql.text := 'select * from table1';   rsdb.open; end; procedure TForm1.Button2Click(Sender: TObject); begin   close end; //saving procedure TForm1.Button3Click(Sender: TObject); begin if Button3.caption := 'new' then begin rsdb.insert; Button3.caption := 'save'; end else begin if (dbedit1.text= '') or (dbedit1.text='') then begin // end else begin rsdb.post; rsdb.applyupdates; trdb.commitretainning; end; Button3.caption := 'new'; end; end; asdf? Have you visited my sqlite sample code project? it has the ability to add, delete, update records. you just have to change a little if you want to change from sqlite to firebird. please see the codes, so you can determined how tos. http://wiki.lazarus.freepascal.org/User:Rocarobin ---------------------------------------------------------------------- motaz · 2010-10-23 11:53 I've asked this question when I start development of Turbo Bird project.  Now it is there http://www.code.sd