Interface Cantik dengan Skin Component Gratis

Thursday, August 7, 2008
Tidak banyak Skin Component gratis yang tersebar di internet
apalagi yang cukup professional untuk mempercantik Aplikasi yang kita buat. Ada satu website yang menyediakan Skin Component package gratis untuk kamu download dan gunakan. Di artikel ini saya akan mengulas sedikit tentang Delphi Skin Component gratis ini beserta screenshot Demo aplikasi yang telah ditambahkan Skin Component diatas.

AlphaControls Lite Edition v.5


AlphaControls Demo Application
AlphaControls Lite Edition v.5 adalah versi gratis dari AlphaControls Component Package dari www.alphaskins.com AlphaControls Lite Edition berisi 13 Component yaitu : TsSkinManager, TsSkinProvider, TsEdit, TsCheckBox, TsPanel, TsButton, TsScrollBar, TsLabel, TsWebLabel, TsBitBtn, TsComboBox, TsListBox and TsGauge. semua komponen diatas bisa kamu download dan kamu gunakan dalam aplikasi yang kamu buat baik itu yang freeware ataupun aplikasi yang komersial tanpa dipungut biaya alias free. Di halaman download website resminya Alpha Controls www.alphaskins.com/dwnld.php, terdapat lebih dari 30 skin dan beberapa tool diantaranya Skin Editor dan project converter yang bisa kamu download secara gratis.

Masih ga percaya, nih deskripsi dari publishernya :
AlphaControls Lite edition (Free for using in any projects!)
Package contains 13 absolutely free and fully-functional components from the AlphaControls package (TsSkinManager, TsSkinProvider, TsEdit, TsCheckBox, TsPanel, TsButton, TsScrollBar, TsLabel, TsWebLabel, TsBitBtn, TsComboBox, TsListBox and TsGauge). Skinning of most standard edit controls by the TsSkinProvider component is available also. By using these components you can see the basic ideas behind AlphaControls which distinguish these components from similar packages. Supported Delphi 5/6/7/2005/2006. Small compiled demo with sources included in this package.

Setelah kamu install, Skin Component ini sangat mudah untuk diaplikasikan ke program yang kamu buat. Kamu tinggal tambahkan komponen TsSkinManager TsSkinManager dan TsSkinProvider TsSkinProvider ke dalam form lalu atur properties dari TsSkinManager sebagai berikut :

SkinDirectory : arahkan ke folder yang berisi skin dari komponen AlphaControls (ada 3 buah skin yang disertakan dalam paket downloadnya yang terdapat di folder ASLDemo)
SkinName : pilih nama skin yang akan kamu pakai misalnya WMP11
Active : True


dibawah ini adalah screenshot contoh aplikasi dalam artikel saya sebelumnya yang sudah di-skinned :

AlphaControls Demo Application

Download AlphaControls Lite Edition disini (2935 kb)

Menyisipkan Judul Report didalam Statement SQL

Wednesday, August 6, 2008
Inti dari tutorial ini adalah menunjukan bagaimana caranya menyisipkan string reguler didalam statement SQL. String reguler disini maksudnya adalah string yang bukan nilai dari sebuah table di dalam Database. Contoh :

SELECT 'Daftar Produk (Seluruh)' AS Judul, ProductID,ProductName
FROM Products

Judul ProductID ProductName
------------- ----------- ----------------------------------------
Daftar Produk 17 Alice Mutton
Daftar Produk 3 Aniseed Syrup
Daftar Produk 40 Boston Crab Meat
Daftar Produk 60 Camembert Pierrot
Daftar Produk 18 Carnarvon Tigers
Daftar Produk 1 Chai
. . . .
. . . .

77 rows selected

Statement SQL diatas akan menambahkan kolom JUDUL yang berisi nilai yang sama pada output query nya. nilai-nilai yang ada dibawah kolom JUDUL bukan merupakan nilai-nilai yang ada di table PRODUCTS, melainkan string biasa yang kita sertakan dalam Statement SQL nya. dibawah ini saya akan memperlihatkan contoh bagaimana metode ini dipakai untuk menyisipkan judul laporan yang berbeda kedalam SQL Statement menggunakan hanya satu komponen FastReport di Delphi.

Cara ini biasa saya gunakan untuk menghasilkan judul report berdasarkan parameter yang saya inputkan. misalnya saya akan menampilkan laporan daftar produk per supplier dan ingin agar judul report sesuai dengan nama supplier yang ingin saya cetak misalnya judul report nya ingin seperti ini : 'Daftar Produk Supplier : PT. ABC', 'Daftar Produk Supplier : PT. XYZ' dst dengan catatan struktur kolom dari report tersebut sama. Jadi parameternya saya sisipkan kedalam SQL Statement yang digunakan untuk pengambilan datanya. Sebagai contoh dibawah ini saya perlihatkan bagaimana caranya menyisipkan judul untuk report kedalam sebuah SQL statement menggunakan komponen FastReport dan ADOQuery di Delphi.

procedure TForm1.Button1Click(Sender: TObject);
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('SELECT ');
adoquery1.SQL.Add('''Daftar Produk Supplier : ''+a.CompanyName as Judul,');
adoquery1.SQL.Add('B.ProductID,A.CompanyName,b.ProductName,');
adoquery1.SQL.Add('b.QuantityPerUnit,b.UnitPrice,b.UnitsInStock ');
adoquery1.SQL.Add('FROM suppliers a, Products b ');
adoquery1.SQL.Add('where a.SupplierID=b.SupplierID ');
adoquery1.SQL.Add('AND a.CompanyName = :CN');
adoquery1.Parameters[0].Value := combobox1.Text;
adoquery1.Prepared := true;
adoquery1.Open;

//kalau data ada
if adoquery1.RecordCount > 0 then
frxReport1.ShowReport();

end;


kamu bisa lihat didalam Statement SQL diatas saya sisipkan string 'Daftar Produk Supplier :' yang digabung dengan nilai CompanyName dari table Suppliers yang kemudian dialiaskan sebagai kolom/field Judul yang nantinya field/kolom Judul ini akan saya tempatkan di report sebagai judul report. agar lebih jelas kamu bisa lihat gambar dibawah ini :

Report Design
Report Design

Application Runtime
Application Runtime


Report Runtime
Report Runtime

Dengan metode ini kamu bisa memberikan judul report yang lebih detail tanpa harus memboroskan pemakaian komponen untuk mencetak berbagai report yang mempunyai struktur kolom yang sama.

Download Source Code Aplikasi ini disini.

Combobox dengan Dua Kolom (Field)

Friday, July 25, 2008

Menampilkan nilai dari dua field atau lebih dalam satu combobox.


di dalam artikel ini saya akan sharing tips ringan pemrograman Delphi untuk menampilkan nilai dari dua kolom/field dari sebuah table di database menggunakan komponen DBLookupComboBox. disini saya akan menggunakan sebuah database yang dibuat dengan Microsoft Access.



Buat Project baru dan tambahkan sebuah komponen ADOConnection, ADOTable, dan sebuah DataSource ke dalam form. Hubungkan komponen ADOConnection di atas dengan table di database yang kamu pilih. Setelah koneksi dengan Database Microsoft Access sukses, langkah selanjutnya adalah menghubungkan komponen ADOTable ke komponen ADOConnection dan hubungkan juga komponen DataSource ke ADOTable.



Tambahkan komponen DBLookupComboBox (Tab DataControls) ke dalam form. set properties ListSource ke komponen DataSource dan KeyField ke salah satu field dari table yang kamu pakai. Untuk menampilkan dua field atau lebih dalam DBLookupComboBox kamu ketik manual nama-nama field yang ingin kamu tampilkan dalam komponen DBLookupComboBox - setiap field dipisahkan dengan titik koma (;) misalnya : productid;descriptions.




Application Design Time






DBLookupComboBox Properties








Application Run Time


SQL : Using subquery to resolving query problems

Sunday, July 13, 2008
When working with databases and records sometimes we find difficulties in displaying data from many tables using SQL join. For example you wish to include some aggregate columns from three tables below :

the structure of the products table :


ProductID text(15),
VendorID text(15),
Descriptions text(50),
UnitsInStock integer,
Price integer

Data in the products table :



ProductID VendorID Descriptions UnitsInStock
---------- -------- ------------------------------------------ ------------
SDB0001 V0001 MS SQL Server Database 2005 5
SDB0002 V0002 Oracle Database 10g Enterprise 6
SDB0003 V0003 MySQL 5.0 Enterprise Edition 8
SDBA0001 V0004 Navicat For MySQL Administration 6
SDBA0002 V0005 Dreamcoder 4.1 For MySQL Enterprise 4
SDBA0003 V0005 Dreamcoder 4.1 For MySQL Profesional 8
SDBA0004 V0005 Dreamcoder 4.1 For MS SQL Server Database 4





the structure of the Purchasing table :


ProductID text(15),
VendorID text(15),
PurchaseDate date,
Quantity integer

Data in the Purchasing table :



ProductID PurchaseDate Quantity
---------- ------------ --------
SDB0001 7/1/2008 10
SDB0002 7/1/2008 12
SDB0003 7/1/2008 12
SDBA0001 7/1/2008 8
SDBA0002 7/1/2008 3
SDBA0003 7/1/2008 8
SDBA0004 7/1/2008 8
SDB0001 7/2/2008 7
SDB0002 7/2/2008 9
SDB0003 7/2/2008 7
SDBA0001 7/2/2008 7
SDBA0002 7/2/2008 3
SDBA0003 7/2/2008 7
SDBA0004 7/2/2008 7




the structure of the sales table :


ProductID text(15),
VendorID text(15),
SalesDate date,
Quantity integer

Data in the sales table :



ProductID SalesDate Quantity
---------- ------------ --------
SDB0001 7/1/2008 8
SDB0002 7/1/2008 8
SDB0003 7/1/2008 9
SDBA0001 7/1/2008 4
SDBA0002 7/1/2008 1
SDBA0003 7/1/2008 2
SDBA0004 7/1/2008 5
SDB0001 7/2/2008 4
SDB0002 7/2/2008 7
SDB0003 7/2/2008 2
SDBA0001 7/2/2008 5
SDBA0002 7/2/2008 1
SDBA0003 7/2/2008 5
SDBA0004 7/2/2008 6


there is two productid that have the same values in each of sales and purchasing table. Now you want to display how many quantity bought, quantity sold, and quantity available now by joining three tables above so that query output give you the clear information concerning all products.



I will show you how this can confusing when its done by a query especially for SQL newbies. below is an example of wrong SQL statement that will give you incorrect information about the data :



SELECT a.productid, a.descriptions,
sum(b.quantity) AS prchqty,
sum(c.quantity) as salesqty, a.unitsinstock
FROM products AS a, purchasing AS b, sales c
WHERE a.productid=b.productid
and a.productid=c.productid
GROUP BY a.productid, a.descriptions, a.unitsinstock



query output:



productid descriptions prchqty salesqty unitsinstock
--------- ------------------------------------------ ------- -------- ------------
SDB0001 MS SQL Server Database 2005 34 24 5
SDB0002 Oracle Database 10g Enterprise 42 30 6
SDB0003 MySQL 5.0 Enterprise Edition 38 22 8
SDBA0001 Navicat For MySQL Administration 30 18 6
SDBA0002 Dreamcoder 4.1 For MySQL Enterprise 12 4 4
SDBA0003 Dreamcoder 4.1 For MySQL Profesional 30 14 8
SDBA0004 Dreamcoder 4.1 For MS SQL Server Database 30 22 4


the query output above giving incorrect information for the prchqty and salesqty column. it is caused by there are more than one productid which have the same values in each of the purchasing table and the sales table so that when you join the tables using productid column the query output will display the column quantity become twice from real quantity.



to resolving this problem you can use a view and or a subquery but in this tutorial I will only show how to use subqueries to resolving the problem. below is the right SQL statement which will give a correct information about the data (note : this query will not working in previous version of MySQL 6, paradox database, and interbase 6) :



SELECT a.productid, a.descriptions,
sum(b.quantity) AS prchqty, c.salesqty,a.unitsinstock
FROM products AS a, purchasing AS b,
(select productid,sum(quantity) as salesqty
from sales
group by productid) AS c

WHERE a.productid=b.productid
and a.productid=c.productid
GROUP BY a.productid, a.descriptions,
c.salesqty, a.unitsinstock


query output :



productid descriptions prchqty salesqty unitsinstock
--------- ------------------------------------------ ------- -------- ------------
SDB0001 MS SQL Server Database 2005 17 12 5
SDB0002 Oracle Database 10g Enterprise 21 15 6
SDB0003 MySQL 5.0 Enterprise Edition 19 11 8
SDBA0001 Navicat For MySQL Administration 15 9 6
SDBA0002 Dreamcoder 4.1 For MySQL Enterprise 6 2 4
SDBA0003 Dreamcoder 4.1 For MySQL Profesional 15 7 8
SDBA0004 Dreamcoder 4.1 For MS SQL Server Database 15 11 4


in the above query, string which in bold is subquery or which I call inline view. the subquery above will produce productid column and salesqty column which the data is taken from the sales table which then aliased as table C, so that each productid from the products table (A) will be joined to one productid in the purchasing table (B) and sales table (C).

Delphi Tips : Displaying Image in DBGrid Columns

In this tutorial I will share tips about how to displaying image in the DBGrid columns. You can use this method to mark rows that meet certain conditions matching with the conditions you specified. The components which I use is a TDBGrid, a TDatasource, and it is of course a TADOTable which is connected to a table in a Microsoft Access database. Set each of the component properties so that the components is connected to each other.





The following example show how images is used to mark the records base on value on the UnitsInStock column.


condition :

the product which its UnitsInStock value greater or equal to 10 is marked with a checklist image (checklist.bmp) and product which its UnitsInStock less than 10 is marked with a warning image (warning.bmp).



The Code


procedure TForm1.DBGrid1DrawColumnCell
(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn;
State: TGridDrawState);

var
Image : TBitMap;
begin
Image := TBitmap.Create;

try
with Image do begin
Transparent := True;
TransParentColor := Image.Canvas.Brush.Color;
TransparentMode := tmAuto;
end;

{ Image will only displayed if the table is not empty }
if DataSource1.DataSet.RecNo > 0 then
begin
if Column.Title.Caption = 'Stock OK' then
begin
{ if the quantity > 10 }
if (ADOTable1.FieldValues['unitsinstock'] > 10) then
begin
Image.LoadFromFile
(ExtractFilePath(Application.ExeName)+'\good.bmp');
DBGrid1.Canvas.Draw(rect.Left + 2,Rect.Top,Image);
end;

{ if the quantity > 0 and <= 10 }
if (ADOTable1.FieldValues['unitsinstock'] > 0)
and (ADOTable1.FieldValues['unitsinstock'] <= 10) then
begin
Image.LoadFromFile
(ExtractFilePath(Application.ExeName)+'\warning.bmp');
DBGrid1.Canvas.Draw(rect.Left + 2,Rect.Top,Image);
end;

end;
end;

finally
Image.Free;
end;

end;






You can download the source code here

Delphi How To: Creating Calculation Field

Wednesday, June 11, 2008

In this Delphi Tutorial i will explain how to create a calculation field on Delphi DBAware component and show it on the DBGrid. Calculation Field is an additional field that we can create to do automatic calculation at OnCalcFields event.



For example you have a table called SalesDetail that have the following structure :


Table Structure

if you want your Application to do automatic calculation for the total price (UnitPrice * Quantity) as you insert or edit Data, you can follow this steps :




1. Creating Calculation Field On TADOTable Component



  • Add TADOTable Component to a Form

  • Set its ConnectionString and TableName properties so its connected to your Database

  • Right click on the TADOTable component and choose Fields Editor... the Fields Editor will appear

  • Right click on the Fields Editor and choose Add All Fields to include all field in the Table

  • Right Click on Fields Editor and choose New Field... the New Field Dialog will appear

  • Enter a name for this new field in the Name textbox for example CTotal

  • Choose Number Data Type (Integer, Float, Largeint, etc depend on posible value range you will need) on Type combobox

  • Choose Calculated in the Field Type Section and then click the OK button






  • Now you have created a calculation Field called CTotal








2. Adding Code to your Application to do Automatic Calculation



  • Add a DataSource component to the form and connect it to your TTable or TADOTable Component.

  • Add a DBGrid component to the form and connect it to your DataSource Component

  • set the AutoCalcFields Properties of TADOTable Component to True.

  • To do automatic calculation as you insert or edit Data, add this code on OnCalcFields event of TADOTable component

  • AdoTable1.FieldValues['CTotal'] :=

    AdoTable1.FieldValues['UnitPrice'] * AdoTable1.FieldValues['Qty'];




Designtime


Application Designtime


Runtime


Application Runtime



Download Sourcode here

SQL BETWEEN: Searching Between Two Specified Values (Range)

Monday, June 9, 2008

Syntax


expression [ NOT ] BETWEEN lower_value AND higher_value



The SQL BETWEEN Operator are used to display rows between two specified values. The lower value are placed before AND operator and the higher value are placed after AND operator.


For Example you have a table called Articles that contain the following Data:




ArticleID Title PageView PublishDate
--------- ------------------------- ----------- -------------------
1 SQL JOIN Example 43 2008-06-04 15:18:00
2 SQL BETWEEN Example 84 2008-06-07 15:23:00
3 SQL Where Example 0 2008-06-07 15:27:00
4 SQL: Find Duplicate Values 102 2008-05-29 15:30:00
5 SQL HAVING Example 50 2008-03-19 15:33:00





Using SQL Between on Numeric Data Type Field


The following SQL Statement example will return Articles that having PageView Between 50 and 100:




Select ArticleID,Title,PageView,PublishDate

from Articles

where PageView Between 50 and 100



Query Result:


ArticleID Title PageView PublishDate
--------- ------------------------- ----------- -------------------
2 SQL BETWEEN Example 84 2008-06-07 15:23:00
5 SQL HAVING Example 50 2008-03-19 15:33:00






Using SQL Between on Date Data Type Field


The following SQL Statement example will return Articles published between 29th May 2008 and 8th June 2008 :




Select ArticleID,Title,PageView,PublishDate

from articles

where PublishDate between '29-may-2008' and '08-jun-2008'



Query Result


ArticleID Title PageView PublishDate
--------- ------------------------- ----------- -------------------
1 SQL JOIN Example 43 2008-06-04 15:18:00
2 SQL BETWEEN Example 84 2008-06-07 15:23:00
3 SQL Where Example 0 2008-06-07 15:27:00
4 SQL: Find Duplicate Values 102 2008-05-29 15:30:00






you can use SQL Statement bellow if you work with a MS Access Database. it will produce the same result



Select ArticleID,Title,PageView,PublishDate

from articles

where PublishDate between #01/06/2008# and #08/06/2008#





To display rows outside the range you specified, you must omits NOT operator before BETWEEN operator. Example :




Select ArticleID,Title,PageView,PublishDate

from Articles

where PageView Not Between 50 and 100


Query Result


ArticleID Title PageView PublishDate
--------- ------------------------- ----------- -------------------
1 SQL JOIN Example 43 2008-06-04 15:18:00
3 SQL Where Example 0 2008-06-07 15:27:00
4 SQL: Find Duplicate Values 102 2008-05-29 15:30:00

Using SQL Outer Join

When you use SQL JOIN/INNER JOIN, the result are rows that only matches in both table based on Join condition you specified in the FROM clause. If you need to display all rows from at least one of the tables mentioned in the FROM clause, you can use SQL OUTER JOIN statement. There are 3 types of SQL Outer Join. Outer joins are specified with one of the following sets of keywords when they are specified in the FROM clause:




LEFT JOIN or LEFT OUTER JOIN : Left Outer Join includes all the rows from the left table specified in the LEFT OUTER clause, not just the ones in which the joined columns match. When a row in the left table has no matching rows in the right table, the associated result set row contains null values for all select list columns coming from the right table.


RIGHT JOIN or RIGHT OUTER JOIN : A right outer join will return All rows from the right table and Null values are returned when there are no matching row in the left table.



FULL JOIN or FULL OUTER JOIN : A full outer join returns all rows in both the left and right tables. Null values given for any rows that has no match in both tables.



For example you have the following tables and data in your database:




Data in the Vendors table:


VendorID VendorName
--------- ------------------------------
V0001 Microsoft Corporation
V0002 Oracle Corporation
V0003 MySQL AB
V0004 PremiumSoft CyberTech Ltd.
V0005 Mentat Technologies
V0006 FastReport Inc.
V0007 CoreLab





Data in the Products table:


ProductID VendorID Description
---------- --------- -----------------------------------------
SDB0001 V0001 MS SQL Server Database 2005
SDB0002 V0002 Oracle Database 10g Enterprise
SDB0003 V0003 MySQL 5.0 Enterprise Edition
SDBA0001 V0004 Navicat For MySQL Administration
SDBA0002 V0005 Dreamcoder 4.1 For MySQL Enterprise
SDBA0003 V0005 Dreamcoder 4.1 For MySQL Profesional
SDBA0004 V0005 Dreamcoder 4.1 For MS SQL Server Database
SDBA0005 V0008 PostgreSQL Maestro
SDBA0006 V0008 Firebird Maestro
SDBA0007 V0008 SQLite Maestro



You noticed that Vendor V0008 doesn't exist in the Poducts table and V0006, V0007 doesn't exist in the Vendors Table. This rows will not be displayed if you use a regular SQL JOIN/INNER JOIN (where Vendors.VendorID=Products.VendorID). How to display all rows from the Vendors table although it doesnt exist on the Products table or the reverse?.




Left Join or Left Outer Join Example:

The Following SQL Statement will display all rows from the Vendors table and will display only rows from the Products table that match to the Vendors table based on VendorID field.



select Vendors.VendorID,products.ProductID,products.Description

from vendors LEFT JOIN products

on vendors.vendorid=products.vendorid



Query Result:


VendorID ProductID Description
--------- ---------- -----------------------------------------
V0001 SDB0001 MS SQL Server Database 2005
V0002 SDB0002 Oracle Database 10g Enterprise
V0003 SDB0003 MySQL 5.0 Enterprise Edition
V0004 SDBA0001 Navicat For MySQL Administration
V0005 SDBA0002 Dreamcoder 4.1 For MySQL Enterprise
V0005 SDBA0003 Dreamcoder 4.1 For MySQL Profesional
V0005 SDBA0004 Dreamcoder 4.1 For MS SQL Server Database
V0006 NULL NULL
V0007 NULL NULL






Right Join or Right Outer Join Example::

The Following SQL Statement will display all rows from the Products table and display only rows from the Vendors table that match to the Products table based on VendorID field.




select Vendors.VendorID,products.ProductID,products.Description

from vendors RIGHT JOIN products

on vendors.vendorid=products.vendorid



Query Result:


VendorID ProductID Description
--------- ---------- -----------------------------------------
V0001 SDB0001 MS SQL Server Database 2005
V0002 SDB0002 Oracle Database 10g Enterprise
V0003 SDB0003 MySQL 5.0 Enterprise Edition
V0004 SDBA0001 Navicat For MySQL Administration
V0005 SDBA0002 Dreamcoder 4.1 For MySQL Enterprise
V0005 SDBA0003 Dreamcoder 4.1 For MySQL Profesional
V0005 SDBA0004 Dreamcoder 4.1 For MS SQL Server Database
NULL SDBA0005 PostgreSQL Maestro
NULL SDBA0006 Firebird Maestro
NULL SDBA0007 SQLite Maestro




Full Join or Full Outer Join Example::

The Following SQL Statement will display all rows from both Vendors and Products table.




select Vendors.VendorID,products.ProductID,products.Description

from vendors FULL JOIN products

on vendors.vendorid=products.vendorid



Query Result:


VendorID ProductID Description
--------- ---------- -----------------------------------------
V0001 SDB0001 MS SQL Server Database 2005
V0002 SDB0002 Oracle Database 10g Enterprise
V0003 SDB0003 MySQL 5.0 Enterprise Edition
V0004 SDBA0001 Navicat For MySQL Administration
V0005 SDBA0002 Dreamcoder 4.1 For MySQL Enterprise
V0005 SDBA0003 Dreamcoder 4.1 For MySQL Profesional
V0005 SDBA0004 Dreamcoder 4.1 For MS SQL Server Database
NULL SDBA0005 PostgreSQL Maestro
NULL SDBA0006 Firebird Maestro
NULL SDBA0007 SQLite Maestro

SQL JOIN : Retrieving Data from many Tables

Joins are created when we display Data in queries that using more than one tables. we can connect a row in one table to another row in other table using the same value of both rows. Usualy this relation represented as Primary Key and Foreign Key relationship.


Joins allow an association between a field in one table or view with a field of the same data type in another table or view. Joins show how the data in one table relates to the data in another table. By using joins, data from two or more tables or queries based on logical relationships among the tables can be retrieved. Joins can be added, edited, or deleted to retrieve the data from the database.


For Example you have two tables called Products and Vendors that contain the following Data:



Data in table Vendors:


VendorID VendorName URL
--------- --------------------------- --------------------------
V0001 Microsoft Corporation http://www.microsoft.com
V0002 Oracle Corporation http://www.oracle.com
V0003 MySQL AB http://www.mysql.com
V0004 PremiumSoft CyberTech Ltd. http://www.navicat.com
V0005 Mentat Technologies http://www.mentattech.com



Data in table Products:


ProductID VendorID Description
---------- --------- -----------------------------------------
SDB0001 V0001 MS SQL Server Database 2005
SDB0002 V0002 Oracle Database 10g Enterprise
SDB0003 V0003 MySQL 5.0 Enterprise Edition
SDBA0001 V0004 Navicat For MySQL Administration
SDBA0002 V0005 Dreamcoder 4.1 For MySQL Enterprise
SDBA0003 V0005 Dreamcoder 4.1 For MySQL Profesional
SDBA0004 V0005 Dreamcoder 4.1 For MS SQL Server Database



Bellow is SQL JOIN Statement example to display ProductID, VendorName, and Description by Joining two tables above




select products.ProductID,vendors.VendorName,products.Description

from vendors, products

where vendors.vendorid=products.vendorid



Query Result:


ProductID VendorName Description
---------- -------------------------- -----------------------------------------
SDB0001 Microsoft Corporation MS SQL Server Database 2005
SDB0002 Oracle Corporation Oracle Database 10g Enterprise
SDB0003 MySQL AB MySQL 5.0 Enterprise Edition
SDBA0001 PremiumSoft CyberTech Ltd. Navicat For MySQL Administration
SDBA0002 Mentat Technologies Dreamcoder 4.1 For MySQL Enterprise
SDBA0003 Mentat Technologies Dreamcoder 4.1 For MySQL Profesional
SDBA0004 Mentat Technologies Dreamcoder 4.1 For MS SQL Server Database





Or you can use this form of SQL JOIN, will produce the same result



select products.ProductID,vendors.VendorName,products.Description

from vendors inner join products

on vendors.vendorid=products.vendorid



Query Result:


ProductID VendorName Description
---------- --------------------------- -----------------------------------------
SDB0001 Microsoft Corporation MS SQL Server Database 2005
SDB0002 Oracle Corporation Oracle Database 10g Enterprise
SDB0003 MySQL AB MySQL 5.0 Enterprise Edition
SDBA0001 PremiumSoft CyberTech Ltd. Navicat For MySQL Administration
SDBA0002 Mentat Technologies Dreamcoder 4.1 For MySQL Enterprise
SDBA0003 Mentat Technologies Dreamcoder 4.1 For MySQL Profesional
SDBA0004 Mentat Technologies Dreamcoder 4.1 For MS SQL Server Database

MySQL Connector Download

Tuesday, June 3, 2008

MySQL provide standard database driver connectivity for using MySQL with applications and tools that are compatible with industry standards ODBC and JDBC. This enables MySQL to work easily with standard development tools on Windows, Linux, Macintosh and Unix platforms. Any system that works with ODBC or JDBC can use MySQL.



  • Connector/ODBC: Standardized database driver Windows, Linux, Mac OS X, and Unix platforms.

  • Connector/J: Standardized database driver for Java platforms and development.

  • Connector/Net: Standardized database driver for .NET platforms and development.

  • Connector/MXJ: MBean for embedding the MySQL server in Java applications.

  • MySQL native driver for PHP - mysqlnd: The MySQL native driver for PHP is an additional, alternative way to connect from PHP 6 to the MySQL Server 4.1 or newer.



MySQL Connector/ODBC 5.1


Version 5.1 of the MyODBC driver is now released by MySQL AB and available for download. An ODBC (Open Database Connectivity) driver enables client programs to access a database or data source. The new version 5.1 MySQL ODBC driver is a greatly enhanced successor version to the existing MyODBC 3.51, rewritten to follow the ODBC 5.1x specifications. It provides complete and up-to-date ODBC functionality when accessing any MySQL database. This latest version is available under the GPL license as well as under commercial license.




MySQL Connector/Net 5.1



Connector/Net 5.1 is the most exciting release of MySQL's fully managed ADO.Net provider to date. Some of the most user-requested features have been included. For example:



  • Support for fully commented stored procedures.

  • Support for Compact Framework 2.0.

  • Support for ASP.Net 2.0 Membership and Role systems.



This release also represents a change in the product packaging. In the past, MySQL AB provided separate downloads for MySQL AB Visual Studio integration product. this product has been merge into a single installer For a better "out of box" experience.



NOTE: By downloading the software from this page, you acknowledge that the software available from here is licensed under the GPL. We advise that you review the GPL before downloading. If you need commercial, non-GPL, licenses, you can order them online.



MySQL Connector/J 5.1


MySQL Connector/J is the official JDBC driver for MySQL. Connector/J 5.1 includes support for JDBC-4.0 functionality, including:



  • Ease-of-development features including auto-registration with the DriverManager via the service provider mechanism, standardized Connection validity checks and categorized SQLExceptions based on recoverability/retry-ability and class of the underlying error.

  • Unwrapping to interfaces that include vendor extensions

  • Support for XML processing via JAXP interfaces to DOM, SAX and StAX

  • Support for setting per-connection client information (which can be viewed in the comments section of a query via "SHOW PROCESSLIST" on a MySQL server, or can be extended to support custom persistence of the information via a public interface)

  • Support for JDBC-4.0 NCHAR, NVARCHAR and NCLOB types



MySQL native driver for PHP - mysqlnd



The MySQL native driver for PHP is an additional, alternative way to connect from PHP 5 and PHP 6 to the MySQL Server 4.1 or newer. It is a replacement for the libmysql, the MySQL Client Library. From now on you can use ext/mysqli either together with libmysql as you did in the past or with mysqlnd.



MySQL AB have no plans to remove libmysql support from ext/mysqli, which would break existing applications. They just add a new, superior alternative to their PHP offerings.




MySQL Visual Studio Plugin 1.02



MySQL Tools for Visual Studio is a package that integrates seamlessly into Visual Studio 2005. This package is currently available under a commercial, no-charge binary license but we are planning to release the source code under an approved open source license within the next few weeks.


The package provides the following features:



  • DDEX capability

  • Database object manipulation (tables, stored procedures, etc)




Publisher : MySQL AB

Download MySQL Connector/ODBC 5.1 (Windows MSI Installer) : Here (4.1 MB)

Download MySQL Connector/ODBC 5.1 (Linux non RPM packages) : Here (4.3 MB)

Download MySQL Connector/Net 5.1 (sources): Here (3.7 MB)

Download Connector/J 5.1 (ZIP): Here (8.4 MB)

Download MySQL native driver for PHP - mysqlnd Sourcode (tar.gz): Here

Download MySQL Visual Studio Plugin 1.02 (ZIP): Here (650 KB)

Delphi Programming: Restricting User's Input Characters

Friday, May 30, 2008

For Client-Server Application or Application that Access sensitive Data it is commonly use an Authentication through a login form. you can enhance the security by restricting user to input certain characters in the login form. for example you can restrict user to input only Alphanumeric characters (A-Z,a-z,0-9) for both Username and Password Text. The advantage of this method is to minimize security hole that your application has or minimize the risk of SQL Injection. But the consequences of this method is all registered User must have their Username and Password in Alphanumeric value.



In this Tutorial i will share Delphi Script to restrict certain input characters in a Edit textbox. you must add this code on OnKeyPress Event of an Edit Component. for this tutorial you can add a TEdit(Edit1) and a label (label1).




Code for Restricting character other than Alphanumeric (A-Z,a-z,0-9) :





procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);

var

  SelSt: Integer;

  TmpStr: string;



begin

if not (key in ['a'..'z','A'..'Z','0'..'9',Chr(vk_Back)]) then

  with (Sender as TEdit) do

  begin

    SelSt := SelStart;

    if (Key = Chr(vk_Back)) and (SelLength <> 0) then

    begin

      TmpStr := Copy(Text,1,SelStart)+Copy(Text,SelLength+SelStart+1,255);

      label1.Caption := 'You try to Input : '+tmpstr;

      end

    else if Key = Chr(vk_Back) then

    begin

      TmpStr := Copy(Text,1,SelStart-1)+Copy(Text,SelStart+1,255);

      label1.Caption := 'You try to Input : '+tmpstr;

    end

    else

    begin

      TmpStr := Copy(Text,1,SelStart)+Key+Copy(Text,SelLength+SelStart+1,255);

      label1.Caption := 'You try to Input : '+tmpstr;

    end;



    if TmpStr = '' then Exit;



    if (Key = Chr(vk_Back)) and (SelSt > 0) then Dec(SelSt)

    else if Key <> Chr(vk_Back) then Inc(SelSt);

    Key := #0;

    if SelSt = 0 then

    begin

      Text:= '';

      Exit;

    end;

  end;

end;



Designtime




Runtime


Enterprise Free, OpenSource Database Servers,Database Engines and Database Software

Monday, May 26, 2008

This list of Free Database Server,Database Engines and Database Software you can use it for free or free for non commercial use.



Ingres


Ingres is a proven, high-performance open source relational database solution that offers the scalability, integration and flexibility to leverage information resources across a wide range of platforms, including Linux, UNIX, Windows and OpenVMS.



ScimoreDB


ScimoreDB Distributed SQL database is free shared-nothing clustered database system . The Database server have been designed to take advantage of parallelization over multiple servers, achieving a near linear scalability for OLTP applications. Supporting up to 512 PC's in a single database cluster, ScimoreDB offers value in terms of speed, functionality and cost.TScimoreDB Server is an extremely reliable Enterprise Database. With features such as ACID with full commit, rollback, crash recovery and row level locking, it allows you to build secure, bussiness-critical application. Support T-SQL language enable you to create your own custom and potentially intricate bussiness logic.



Perst


Perst is an object-oriented embedded database for applications that need to deal with persistent data. There are two implementations of Perst - pure Java and pure C# (C Sharp).




H2


H2 is a SQL database engine. Available as Java library and as native executable (using GCJ). Clustering, embedded and server mode, disk based or in-memory operation. JDBC and (partially) ODBC APIs are supported. Support for transactions, referential integrity, triggers, subqueries, views, and encryption. A browser based console application is included. H2 stands for 'Hypersonic 2' and is written by original author of Hypersonic SQL.



HSQLDB


HSQLDB is the leading SQL relational database engine written in Java. It has a JDBC driver and supports a rich subset of ANSI-92 SQL (BNF tree format) plus SQL 99 and 2003 enhancements. It offers a small, fast database engine which offers both in-memory and disk-based tables and supports embedded and server modes. Additionally, it includes tools such as a minimal web server, in-memory query and management tools and a number of demonstration examples.



Microsoft SQL Server 2005 Express Edition



SQL Server Express is a version of SQL Server 2005 designed to helps developers build robust and reliable applications by providing a powerful database that is also free and easy to use.



db4o


db4o (database for objects) is the open source object database for Java and .NET. It is free software available under the GPL and also under a commercial license. It can persist any native object with a single line of code and allows you to experience true object-orientation. Features include: ACID transactions, query-by-example, S.O.D.A. query API and automatic class schema recognition, small footprint.



Sybase ASE Express Edition for Linux


ASE Express Edition is limited to use of one CPU, 5GB of data storage and 2GB of RAM.




IBM Cloudscape V10.0


IBM Cloudscape V10.0 is a pure, open source-based Java relational database management system that can be embedded in Java programs and used for online transaction processing (OLTP).



SQLite


SQLite is a small C library that implements a self-contained, embeddable, zero-configuration SQL database engine



SimpleSQL



SimpleSQL is designed to be a simple to use relational database, for Java, C++, JDBC, PHP, ActiveX, etc.



AidAim SQLMemTabl


SQLMemTable is a fast in-memory database system. Key features: no BDE, no dlls required, SQL support, BLOB compression, fast indexes, import/export, Unicode, comprehensive help. SQLMemTable Personal is free for personal use. Any company must order SQLMemTable Com, Pro, Team4, Team8 or Enterprise to use it in its projects



Berkeley DB


Berkeley DB is an open-source database system made by Sleepycat Software. It is available in several different distributions including a java beta version. You can use them freely if the the complete source code for your application is available and freely redistributable under reasonable conditions. Otherwise you can purchase a license. See the website for licensing information.




Firebird


Firebird is an OpenSource database environment formerly known as Borland Interbase Version 6. Features include full SQL compliancy, stored procedures, and other advance database features.



ObjectDB for Java/JDO


ObjectDB for Java/JDO is a powerful Object Database for Java. It is specially designed to handle efficiently databases of various sizes, from a few KBs to hundreds of GBs, in both embedded database mode and client server mode. As a pure Java Database, ObjectDB for Java/JDO is written entirely in Java, and it is compliant with the new Java Data Objects (JDO) standard.



MySQL database server and standard clients



MySQL is available for many platforms and you can download the server and client software as well as a MySQL ODBC diver and a bunch of other MySQL tools from this page.



postgresql


PostgreSQL is an open source relational database management system and runs on many platforms. You can download the latest release as well as a conversion utility (MySQL to PostgreSQL) from this page.



Hypersonic SQL


hsqldb is a relational database engine written in Java, with a JDBC driver, supporting a rich subset of ANSI-92 SQL (BNF tree format). It offers a small (less than 160k), fast database engine which offers both in memory and disk based tables. Embedded and server modes are available. Additionally, it includes tools such as a minimal web server, in-memory query and management tools (can be run as applets) and a number of demonstration examples. (100% Java Database)




GNU SQL Server


SQL Server is a free portable multiuser relatational database management system. It supports the full SQL89 dialect and has some extensions from SQL92. It provides multiuser access and transaction isolation based on predicative locks. The working OS: UNIX. The working language: C . It also uses RPC, shared memory and message queues.



Mariposa


The Mariposa distributed database management system is an ongoing research project at the University of California at Berkeley. It allows DBMSs which are far apart and under different administrative domains to work together to process queries. Runs on Digital Equipment Alpha running DEC OSF/1 3.2 (with gcc and cc).



Dxstore Database System



The Dxstore Database System is a database management system for Linux, FreeBSD, and other operating systems. In the tradition of dbm/ndbm, it is distributed as an embeddable C or C++ library and shares with them the model of a database as a collection of key/value pairs



DiamondBase


DiamondBase is a C++ database engine which is available for free non commercial use, and is negotiable for commercial use.

InstallCreator 2.0 Free Application Installer

Saturday, May 24, 2008

InstallCreatorInstallCreator Freeware Version is a Software for Creating Application Installer Package

This Freeware Version of InstallCreator contain full feature with some Advertisement Page for ClickTeam on each Installer when the installation is complete, with a button to connect to ClickTeam web site. There are absolutely no limitations in the functionality, and none of those annoying "nag screens" in the software.


Install Creator And Install Creator Pro Feature List



  • Everything in one compressed distributable executable file

  • Follows the standards seen in all installation programs

  • Full-featured dialog box editor to customize your installer's screen

  • Every text is customizable

  • Creates icons and folder in Window's start menu

  • Automatic floppy disk spanning

  • Automatic installation of Fonts

  • Automatic installation of ActiveX controls

  • Automatic installation of screen-savers

  • Handle DLL installation and de-installation counters

  • Optional icon on the desktop

  • Display a text or web page at the end of an installation

  • Launch other programs at the end of an installation

  • Complete de-installer

  • Ability to remove keys from the registry

  • Multilingual templates and you can make your own language translations






  • For Install Creator and Install Creator Pro

  • Windows 95 OSR-2 / 98 / Me / NT 4 / 2000 / XP / Vista or above, with Internet Explorer 4 or above installed

  • 32 Mb RAM

  • hard disk with 4 Mb of free disk space



For the install programs created with Install Creator or Install Creator Pro


  • Windows 95 / 98 / Me / NT 4 / 2000 / XP / Vista or above

  • 16 Mb RAM




What makes this Software Different from other Installers Software




  • Small footprint of the executable

    An empty installer is only 100Kb. We cram the complete professional installation program and the complete de-installer in 100kb! Compare that with other installer programs: minimums of 500Kb. We feel it is inexcusable to have a 500Kb installer!

  • A simple and easily understood interface

    There's no complex scripting language, you simply select a directory that contains the files to install and set options for any special individual files and that's it, you're done.

  • Easy step by step wizard - it's a cinch!

    When the project is done, just save the settings and you can recover the project later and update it at your will.

  • Complete customization

    You can change all the texts, choose any bitmaps, customize each screen of your installer - you can preview the look of the install process at anytime during the creation process.

  • Fully functional freeware version

    The freeware version is fully and completely operational. You will not find a better installer at 10 times the price. You have nothing to lose test it out today. All these features sound obvious and standard - don't they? So why do we still find programs on the Internet that decompress the data files onto the desktop (isn't that annoying?). Then there are the programs without proper de-installation routines, and products that create a directory at the root of your C drive instead of directing the files where you want them.



Publisher : www.clickteam.com

Download Link : Download (2.35 MB)

SXSkinComponents Free for Delphi Freeware Project



SXSkinComponents is a set of visual components. but it's not a usual package of controls. Using this Component Using SXSkinComponents you can easily create An interface with buttons, checkboxes, edits and other controls, design of which is changed like Windows XP Themes and A fully graphical interface with custom images instead of buttons and other controls.



Features:



  • 100% alpha channel support in components drawing.

  • Every skin is describen in a separate skin.ini file.

  • A skin file contains a set of skin styles: genearal and special ones.

  • A general skin style is a set of elements (images or geometrical figures).

  • JPEG, PNG-8 and PNG-24 (with 8-bit transparency) graphic file formats are supported.

  • These figures can be drawn as skin style elements: rectangles, rounded rectangles, circles, polygons and lines.

  • All figures can be drawn with a translucent border and a gradient fill.

  • Using a BoxTile element you can freely design buttons and other controls.

  • Optimized for processors with MMX instructions support.

  • Support Delphi 6, Delphi 7, Delphi 2005, Delphi 2006, C++Builder 6 and C++Builder 2006.

  • Designed for operating systems Windows 98/ME/NT/2000/XP/2003.

  • Full source code is 100% open.



Project License

  • SXSkinComponents source code can be freely distributed by anyone but with no modifications made.

  • Freeware Projects. You can freely use SXSkinComponents in your freeware projects (and not only opensource).

  • Shareware and Commercial Projects. To use SXSkinComponents in your shareware and commercial projects you have to purchase one of these licenses: a Project License or a Company License.

  • Skins (skin.ini files and image files) are totally free and can not be sold by their authors.



Installation Instruction:



  • Download SXSkinComponents distrubution package (choose Full or Source Only). Follow the DOWNLOADS page to do this.

  • Extract contents of the downloaded zip-file to the Delphi (C++Builder) installation folder.

  • Start Delphi (C++Builder) application. Install Delphi (C++Builder) package from Graphics32-1-8-SX2\Packages folder (it is named GR32_DSGN_BDSxxxx, GR32_DSGN_Dx or GR32_DSGN_CBx).

  • Install package from SXSkinComponents\Packages folder (it is named SXSkin_BDSxxxx_D, SXSkin_Dx_D or SXSkin_CBx_D).

  • Ensure that Graphics32-1-8-SX2 and SXSkinComponents folders were added to the Delphi (C++Builder) Library path.



How to Start

To start with SXSkinComponents try to create a simple skinnable application. To do this start Delphi (C++Builder) and open a project from the Template directory of SXSkinComponents distribution package. Then copy the folder Skins to the folder Template. After that follow steps, described on the form.



Pulisher : www.saarixx.info

Download Page : Download

400 Free PNG Icon For Your Application

Friday, May 23, 2008

Enhance Your Application with this 400 Free Icon.

Over 400 Free Icon in 10x10 and 16x16 pixel size ready to enchance your Application Interface. you can use this icon for any personal or commercial purpose/projects - absolutely free.




Publisher: www.pinvoke.com

Download Here (291 KB)

Membuat Aplikasi Database Berbasis Table XML Dengan Delphi 2007

Tuesday, May 20, 2008

Umumnya setiap Aplikasi Database menggunakan File Database dengan format umum seperti Microsoft Access, Paradox, DBase atau jika Aplikasi Database Client-Server akan menggunakan Database Software seperti SQL Server, Oracle dan lain sebagainya. nah Pada tutorial pemrograman Delphi kali ini saya akan sharing cara membuat aplikasi Database dengan Table berbasis file XML. Aplikasi ini cocok untuk Aplikasi Database Desktop single user misalnya seperti aplikasi untuk me-manage daftar situs web penting/favorit kamu atau bisa juga untuk me-manage koleksi film DVD yang kamu punya, dan lain2. ini adalah contoh Aplikasi Database berbasis XML sederhana, namun tujuannya dari artikel ini adalah sharing pengetahuan kepada kamu yang mungkin belum mengetahui cara melakukan manipulasi data ke dalam file format XML yang mencakup Retrieve/Find (Select), Append (Insert), Edit (Update), dan Delete Data.



Disini kita akan membuat aplikasi dengan Delphi 2007 untuk me-manage koleksi website favorit kita misalnya. Field-field Data yang kita butuhkan adalah SiteID, SiteURL, dan SiteDesc. Field SiteID adalah ID unik untuk setiap situs, SiteURL adalah alamat URL website dan terakhir SiteDesc adalah deskripsi dari situs ini bisa kita tambahkan sebagai informasi tambahan isi/tema sebuah website.



Dibawah ini adalah table komponen-komponen yang kita butuhkan berserta nilai beberapa propertiesnya:















































































































































































































































Komponen



Properties



Value



Form1



Name



Fmain




Caption



Katalog Web



ClientDataSet



Name



CDS




FieldDefs



0 - SiteID, DataType: ftInteger, Size: 0

1 - SiteURL, DataType: ftString, Size: 50

2 - SiteDesc, DataType: ftString, Size: 255


Setelah itu klik kanan CDS, kemudian pilih Create Dataset. untuk membentuk struktur dataset diatas




FileName



KatalogWeb.xml



DataSource1



Name



DS




DataSet



CDS



GroupBox1



Name



GBsiteList




Caption



Website List



Edit1



Name



ECari



ListBox1



Name



LBSiteList



GroupBox2



Name



GBNew




Caption



Data Baru



Edit2



Name



ESiteID



Edit3



Name



ESiteURL



Memo1



Name



MSiteDesc



Button1



Name



BtnOK




Caption



OK



Button2



Name



BtnCancel




Caption



Cancel



GroupBox3



Name



GBDetail




Caption



Website Details



DBEdit1



Name



DBESiteID




DataSource



DS




DataField



SiteID



DBEdit2



Name



DBESiteURL




DataSource



DS




DataField



SiteURL



DBMemo1



Name



DBMSiteDesc




DataSource



DS




DataField



SiteDesc



BitBtn1



Name



BtnDel



BitBtn



Name



BtnEdit



Form2



Name



FEdit




Caption



Edit Website



Edit4



Name



ESiteID



GroupBox4



Name



GBEdit




Caption



Detail Website




Enable



False



Edit5



Name



ESiteURL



Memo2



Name



MSiteDesc



Button3



Name



BtnOK




Caption



OK



Button4



Name



BtnCancel




Caption



Cancel




ModalResult



mrCancel




Application Interface


Tambahkan beberapa label kemudian Atur komponen-komponen diatas sehingga Interface nya menjadi seperti gambar di bawah ini :


Application Interface Design


Coding


File KatalogWeb.xml akan kita tempatkan satu folder dengan file exe aplikasi ini. Kita akan menambahkan kode Program untuk membuat file KatalogWeb.xml pada saat aplikasi pertama dijalankan untuk itu kita perlu menambahkan kode Program pada event OnCreate Form1 caranya dobel klik Form1 kemudian tambahkan kode Program dibawah ini :




procedure TFMain.FormCreate(Sender: TObject);

var namafile : string;

begin

  CDS.Close;

  //mendapatkan path absolute file KatalogWeb.xml

  namafile := extractfilepath(application.ExeName)+cds.filename;



  if not FileExists(namafile) then CDS.CreateDataSet;

  CDS.Open;



  //mengosongkan item pada SiteList

  LBSiteList.Clear;

  LBSiteList.Items.BeginUpdate;



  //membuka dan menampilkan recordset

  CDS.First;

  while not CDS.Eof do

  begin

    LBSiteList.Items.Add(CDS.FieldByName('SiteURL').AsString);

    CDS.Next;

  end;



  LBSiteList.Items.EndUpdate;

  ESiteID.Text := IntToStr(Succ(LBSiteList.Items.Count));

end;



Variabel NamaFile digunakan untuk menampung path lengkap (absolute path) nama file dari file XML yang akan kita gunakan sebagai tempat penyimpanan data aplikasi ini. function ExtractFilePath(application.ExeName) akan mendapatkan path lengkap dimana file .exe aplikasi ini berada. jadi jika kamu menempatkan aplikasi ini pada folder C:\Programming\Delphi\Database\Katalog Web\WebCatalog.exe misalnya, maka function ini akan menghasilkan string C:\Programming\Delphi\Database\Katalog Web\. Sehingga kode program extractfilepath(application.ExeName)+CDS.filename akan menghasilkan string path lengkap ke file KatalogWeb.xml dalam contoh saya adalah C:\Programming\Delphi\Database\Katalog Web\KatalogWeb.xml.



Menambahkan Data


Dobel klik BtnOK pada form FMain kemudian tambahkan kode Program berikut





procedure TFMain.BtnOKClick(Sender: TObject);

begin

  CDS.AppendRecord([StrToInt(ESiteID.Text), ESiteURL.Text, MSiteDesc.Text]);

  ECari.Clear;



  // refresh listbox daftar web

  LBSiteList.Clear;

  LBSiteList.Items.BeginUpdate;



  //membuka dan menampilkan recordset pada LBSiteList

  CDS.First;

  while not CDS.Eof do

  begin

    LBSiteList.Items.Add(CDS.FieldByName('SiteURL').AsString);

    CDS.Next;

  end;

  LBSiteList.Items.EndUpdate;

  ESiteID.Text := IntToStr(Succ(LBSiteList.Items.Count));



  ESiteURL.Clear;

  msitedesc.clear;

  ESiteURL.SetFocus;

end;



Mencari Data


masukan kode Program berikut pada event OnChange komponen ECari





procedure TFMain.ECariChange(Sender: TObject);

const

  SUBSTRING = 'Substring(SiteURL, 1, %d) = ''%s''';

var

  URLPilih: string;

begin

  CDS.Filter := Format(SUBSTRING, [Length(ECari.Text), ECari.Text]);

  //mem-filter dataset jika teks ECari tidak kosong

  CDS.Filtered := ECari.Text <> '';



  LBSiteList.Clear;

  LBSiteList.Items.BeginUpdate;



  //membuka dan menampilkan recordset

  CDS.First;

  while not CDS.Eof do

  begin

    LBSiteList.Items.Add(CDS.FieldByName('SiteURL').AsString);

    CDS.Next;

  end;

  LBSiteList.Items.EndUpdate;



  //mendapatkan nilai SiteID selanjutnya (Successor)

  //berdasarkan jumlah item yg ada di LBSiteList

  ESiteID.Text := IntToStr(Succ(LBSiteList.Items.Count));



  URLPilih := CDS.FieldByName('SiteURL').AsString;

  LBSiteList.ItemIndex := LBSiteList.Items.IndexOf(URLPilih);

end;


Incremental Search


Menampilkan Detail Data Website ketika item di LBSiteList diklik


Dobel klik LBSiteList, masukan kode Program berikut




if LBSiteList.ItemIndex <> -1 then

  CDS.Locate('SiteURL', LBSiteList.Items[LBSiteList.ItemIndex], []);


Application Interface - Runtime

Mengedit Data


Karena Aplikasi ini akan memanggil Form FEdit dari FMain, maka terlebih dahulu deklarasikan unit UEdit di Unit Umain. caranya ketikan Uses UEdit; di bawah implementation pada unit Umain. Setelah itu dobel klik BtnEdit kemudian masukan kode Program berikut pada Unit UMain.pas (Fmain)




with TFEdit.Create(Self) do

begin

  ESiteID.Text := cds.FieldByName('SiteID').AsString;

  ESiteURL.Text := cds.FieldByName('SiteURL').AsString;

  MSiteDesc.Text := cds.FieldByName('SiteDesc').AsString;

  ShowModal;



  if ModalResult = mrOK then

  begin

    CDS.Edit;

    cds.Fields[1].Value := ESiteURL.Text;

    cds.Fields[2].Value := MSiteDesc.Text;

    cds.Post;

    ECari.Clear;



    LBSiteList.Clear;

    LBSiteList.Items.BeginUpdate;

    CDS.First;

    LBSiteList.Clear;

    while not CDS.Eof do

    begin

    LBSiteList.Items.Add(CDS.FieldByName('SiteURL').AsString);

    CDS.Next;

    end;



  LBSiteList.Items.EndUpdate;

  end;

  Free;

end;



dan kode Program berikut pada unit UEdit.pas (FEdit)




procedure TFEdit.BtnOKClick(Sender: TObject);

const

  valid: array[Boolean] of TModalResult = (mrNone, mrOK);

begin

  //modalResult = mrOK jika ESiteURL dan MSiteDesc diisi

  //selain dari itu modalResult = mrNone

  ModalResult := valid[(ESiteURL.Text <> '') and (MSiteDesc.Text <> '')];

  if ModalResult = mrNone then

  MessageDlg('URL dan deskripsi situs harus diisi',

    mtInformation, [mbOK], 0);

end;


Edit Data

Menghapus Data


Dobel klik button btnDel kemudian tambahkan kode Program berikut





const

  konfirmasi = 'Anda akan menghapus alamat URL :'#13;

begin

  //konfirmasi hapus Record

  if MessageDlg(konfirmasi +

    LBSiteList.Items[LBSiteList.ItemIndex] + #13'Lanjutkan?',

    mtConfirmation, mbYesNo, 0) = mrYes then

  begin

    CDS.Delete;

    LBSiteList.Clear;

  LBSiteList.Items.BeginUpdate;



  //membuka dan menampilkan recordset

  CDS.First;

  while not CDS.Eof do

  begin

    LBSiteList.Items.Add(CDS.FieldByName('SiteURL').AsString);

    CDS.Next;

  end;

  LBSiteList.Items.EndUpdate;

  ESiteID.Text := IntToStr(Succ(LBSiteList.Items.Count));

  end;

end;





selengkapnya kamu bisa download Source Code Aplikasi ini disini.

Recent Comments

Tags Cloud

Blogumulus by Roy Tanck and Amanda Fazani