Posts

Reports Fast Report Delphi Example

Image
unit Main; interface {$I CompVer.inc} uses {$IFDEF D6H} Variants, {$ENDIF} Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, DBCtrls, Grids, DBGrids, DB, ABSMain, frxClass, frxDBSet; const DataBaseFileName: String = '..\..\Data\Demos.abs'; type TForm1 = class (TForm) dbDemos: TABSDatabase; ABSTable1: TABSTable; DataSource1: TDataSource; DBGrid1: TDBGrid; DBNavigator1: TDBNavigator; Button1: TButton; frxDBDataset1: TfrxDBDataset; GroupBox1: TGroupBox; Label1: TLabel; frxReport1: TfrxReport; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end ; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin dbDemos.DatabaseFileName := ExtractFilePath(Application.ExeName) + DataBaseFileName; ABSTable1.Open

How to encode a datetime in delphi

function EncodeDateTime ( const AYear : Word ; const AMonth : Word ; const ADay : Word ; const AHour : Word ; const AMinute : Word ; const ASecond : Word ; const AMilliSecond : Word ): TDateTime ; See this example uses DateUtils ; var myDateTime : TDateTime ; begin //Your Code myDateTime := EncodeDateTime ( 2009 , 11 , 28 , 14 , 23 , 12 , 000 ); //Your Code End ; Another option uses SysUtils ; var myDateTime : TDateTime ; begin //Your Code myDateTime := EncodeDate ( 2009 , 11 , 28 )+ EncodeTime ( 14 , 23 , 12 , 000 ); //Your Code end ; The second option works because the  TDatetime  It is stored as a Double ( TDateTime = type Double; ), with the date as the integral part (the  EncodeDate  function returns the integral), and time as fractional part. The date part of the TDateTime represents the number of days that have passed since 12/30/1899. a TDateTime can be any date through 31 Dec 9999 (decimal value

How to save jpg image to database and then load it in Delphi using FIBplus and TImage?

Image
unit uMain; interface {$I CompVer.inc} uses {$IFDEF D6H} Variants, {$ENDIF} Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, DB, DBCtrls, Grids, DBGrids, ABSMain, ABSDecUtil; type TForm1 = class (TForm) tblImages: TABSTable; DBGrid1: TDBGrid; DBImage1: TDBImage; dsImages: TDataSource; GroupBox2: TGroupBox; Label1: TLabel; memQuery: TMemo; tblImagesID: TAutoIncField; tblImagesFilePath: TStringField; tblImagesImage: TBlobField; Label2: TLabel; Label3: TLabel; btnCreateQuery: TButton; btnExecuteQuery: TButton; Label4: TLabel; qryAddImage: TABSQuery; dlgOpen: TOpenDialog; procedure FormCreate(Sender: TObject); procedure btnCreateQueryClick(Sender: TObject); procedure btnExecuteQueryClick(Sender: TObject); procedure memQueryChange(Sender: TObject); private { Private declarations } public { Public declarations } end ; var Form1: T

Delphi XE data access with ADO

Image
Step 1. Open new project Step 2. Insert ADO connection object and ADO table object (rename with your table name) build the database connection with ADO connection Step 3. Add button and and edit box Step 4. double click on button and copy below codes var aa:string; begin aa := 'SELECT * FROM Tablename ';   with tablename do   begin     Active := False;     SQL.Clear;     SQL.Add(aa);     ExecSQL;   end;   tablename.Open;   edit1.Text := Tablename.FieldByName('fieldname').AsString; end;

Object Oriented Programming in Delphi A Guide for Beginners

Image
Object Oriented Programming in Delphi A Guide for Beginners Object Pascal, Delphi’s underlying language, is a fully object oriented language. Simply, this means that the language allows the programmer to create and manipulate objects. In more detail, this means that the language implements the four principles of object oriented programming: Data Abstraction Encapsulation Inheritance Polymorphism As you’ll see, these are complicated names for pretty simple ideas. In teaching 100s of Delphi programmers, I’ve found that getting to grips with Object Oriented programming is the difference between just getting by with Delphi, and really making the most of the product. In this article and the next, I’ll introduce Delphi programmers to the Object Oriented features in Object Pascal, and show how to take advantage of them in your own applications. Even if you’ve used Delphi for a while, you may find these articles a useful review - it’s amazing how much you can do with Delphi wit