Saving Files to a Database using Delphi: Saving Bitmaps to a Database - More components
(Page 3 of 4 )
TADOTable TADOTable is defined as a table-type dataset for retrieving and operating on a recordset produced by a single database table. What are datasets then? Datasets are fundamental units for accessing data from the database. A dataset component represents a set of records which may belong to one particular table or be a result of a query or a stored procedure.
Since we need access to the records of only a single table I would employ the TADOTable component because it provides direct access to all the records of the specified table. The TADOTable component can directly connect to the database using its ConnectionString property but it is always advisable to use a single Connection object to connect to the database. Further, we would also need to set the TableName property of TADOTable to point to the actual table whose recordsets we want to access. The active property of the Table component determines whether the records are available for viewing or editing. To be able to view or edit them we would have to set the active property to true during design time and call the open method during runtime.
TDataSource A TDataSource component is an essential component in every database application and acts as an interface between the dataset and the data aware components. To display records, a data aware component's DataSource property should reference a dataset component which in turn should be linked to an active dataset.
TDBEdit A TDBEdit component is in many ways identical to the standard TEdit component but unlike TEdit, TDBEdit is a data aware component which means it can be linked to a text field in the database. It has a few additional properties including the DataSource property and the DataField property through which it is able to retrieve and post data to database.
TDBImage A TDBImage component is a visual data aware component that can be used to display graphical data from a BLOB field of the current dataset. Like all data aware component it needs to be linked to a DataSource and its DataField property should reference the Blob field in the database.
TDBNavigator TDBNavigator is a database component that provides easy navigation and manipulation of records in the dataset. In fact, it handles most of the database actions including navigating the records, inserting, editing, undoing after editing, refreshing and deleting records. The DBNavigator component uses a DataSource to link to the dataset and the values in the data-aware components can be viewed and manipulated through it. In short a DBNavigator allows you to add most of the basic database operation methods in response to user events without requiring you to write a single line of code.
The TButtonand TOpen Dialog components which I am using are standard controls and have been around for a long time, so I will just assume that you know about them and I will refrain from explaining them. The only thing worth noting is that Button1 is labeled "Load Image."
Next: Creating the application >>
More Delphi-Kylix Articles
More By Danish Ahmed