Link to home
Start Free TrialLog in
Avatar of cekcool
cekcool

asked on

Simple sample to access database for beginner

I am a beginner in Delphi Programing, but i had experience in VB6. Can some one show me a sample of how to access the data in the database(Ms Access) by using both coding and component object.

Imagine the following situation:
Database: myProperty.mdb
SQL Query:
'Select * from tblVehicle where VehicleNo := myVehicleNo'
Table: tblVehicleNo
Column: VehicleNo, Type, color...

Can u show me using Query and other data control?
(Actualy i m not sure how to use the Borland Delphi 6.0 Interfaces to create the database object by using drag and drog. I am not sure wheter BDE or ADO is better and easier)
Avatar of marcoszorrilla
marcoszorrilla

Is better to use ADO.
Bassically you need a ADO connection Component To conecct with Access Database.

AdoQuery or AdoStorProc

With AdoStorProc you build the query in Access and execute from Delphi.
you must use the Name of this query Name:Qr_xxxxx
and Active:True.

With AdoQuery, you must build in Delphi your SQL sentence.

Qr_Faltas.Close;
Qr_Faltas.SQL.Clear;
Qr_Faltas.SQL.ADD('Select tb_employee.Name, tb_employee city');
Qr_Faltas.SQL.ADD('From Tb_Employee');
Qr_Faltas.SQL.ADD('Order by Tb_Employee.name;);

Qr_Faltas.Open;

Best Regards.
Marcos

Dear cekcool

Free online database programming course for beginner Delphi developers. Focus on ADO techniques.
http://www.delphi.about.com/library/weekly/aa010101a.htm?PM=ss12_delphi

Learning DB programming with Delphi.
http://www.delphi.about.com/cs/dbbegin/index.htm

Best Regards

Cesario
ASKER CERTIFIED SOLUTION
Avatar of david-johnstone
david-johnstone

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You could use Opus DirectAccess (www.opus.ch).  It's open source now and it's very fast.  BDE is easier but not as powerful or fast.