Google
 

Jumat, 25 Januari 2008

FBCopy 1.7 released (FB tool)

FBCopy version 1.7 is released. FBCopy is a tool for Firebird. What this tool does? According to it's readme file, this tool is for copy data between Firebird tables and databases. FBCopy is a command-line tool, so you can use it inside batch scripts, cron jobs, etc. Currently, Linux and Windows versions are available.

The capabilities are:
* copying data between databases (sorted by dependency tree)
* copying generator values (since version 1.70)
* comparing table fields
* comparing data (with detailed output in HTML)
* open source under MIT license
* cross platform - works on Windows and Linux
* works with all Firebird versions (tested 1.0 - 2.1)
* easy to integrate into batch jobs
* light for remote use via SSH

You can download this nice tool in here

Rabu, 23 Januari 2008

New Little Feature in Zeos

Hi, there are 2 new methods on TZConnection component, they are:

function ExecuteDirect(SQL : String) : boolean;
function ExecuteDirect(SQL:string; var RowsAffected:integer):boolean;

That methods are to execute SQL DDL statement directly without need of TZQuery.
You can try and test this new feature in the Zeos testing Rev337. If the method not act correctly, you can tell us in the forum.

Firebird Roadmap 2008

The Firebird project already release the FB 2.1 RC1 (vailable for field testing on 64-bit and 32-bit Windows and Linux (MacOSX to follow soon)) and also their roadmap in 2008.

Kamis, 17 Januari 2008

BLOB Field using ZeosDBO 6.6.x

Hi, I want to share how to save and load BLOB from database. The database I use here is Firebird, but I think Zeos behaviour is same. This example below is to save and load the JPEG image into and from Firebird database. If you use bitmap image then you can display it using TDBImage, but for JPEG you cann't do that otherwise you get an error that said that it is not a valid bitmap. So in this code, for display the image from database I use TDBImage with no binding (the datasource property still null). So let's look the code:

The component that I dropped:

uses jpeg, ........
type
TForm1 = class(TForm)
con1: TZConnection;
qr1: TZQuery;
qr1aaa: TStringField; //persistant field that only string value
qr1gambar: TBlobField; //persistent field "gambar" that used to save JPEG image
ds1: TDataSource;
dlgOpen1: TOpenDialog;
dbnvgr1: TDBNavigator;
dbeaaa: TDBEdit; //use binding to connect to field "aaa"
btn1: TButton;
btn2: TButton;
dbimg1: TDBImage;
procedure btn1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

The code:

procedure TForm1.FormShow(Sender: TObject);
begin
//Connect to Database and open query
con1.Connect;
qr1.Close;
qr1.Open;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
//Close query and connection
qr1.Close;
con1.Disconnect;
end;

procedure TForm1.btn1Click(Sender: TObject);
begin
if dlgOpen1.Execute then
begin
//Load JPEG image (or anything type of file) into database
qr1gambar.LoadFromFile(dlgOpen1.FileName);
end;
end;

procedure TForm1.btn2Click(Sender: TObject);
var j:TJPEGImage;
begin
//Display image from database to TDBimage (dbimg1) component
j:=TJPEGImage.Create;
j.Assign(qr1gambar);
dbimg1.Picture.Assign(j);
FreeAndNil(j);
end;


How the code work?
"btn1Click" method is clicked after the dataset is in edit or insert mode, then after it load from file then post it (I use DBNavigator in the above example). And then "btn2Click" is for display image from database to TDBImage component. Simply enough? yes, that's all.

Now, what about other format like Word, Excel or PDF document that you want to extract from the database? (the save method is same). The answer is, save it to file again. Zeos already implement it well, so you can do like this:

qr1gambar.SaveToFile('c:\somefile.doc');

Also simply enough? yes. So don't worry to use BLOB field with Zeos component :)
How about to save/load it from Stream? You can also use "SaveToStream" and "LoadFromStream" method.