Delphi Database Programming Course (7)
Chapter IV data browsing and navigation
Section I set up and connect
Welcome to free tutorials DB Delphi's fourth chapter! Until now, this tutorial explains how to connect to the access database and how to display database tables in the graphics data. In the previous chapter, we discussed a number of "advanced" of database Programming skills (translator increase: compared with beginners in terms of) - Now let us return to the "for beginners" level.
This time, you will learn how to establish a database table can browse the data in the form.
Previous chapter on the use of all the examples so that the number of data (data-enabled) components (ADOTable, DBGrid ...) are not sufficient to explain each component in order to achieve what is the function of design, all the data components how to connect. This chapter will explain.
To work (Working together ...)
ADO based database application in Delphi, the components panel in the Data Controls page, ADO pages and pages on the Data Access components to allow our applications from the database to read and write information.
Each data visualization (data-aware) of the (ADO) delphi form, usually contain:
- Number of data visualization components (Data Controls page), but used to create a user interface (data form the exterior).
- A DataSource component (Data Access Page), as a form of data sets and data visualization components of an excuse for control.
- Data set of one or more components (ADO page), provide a database table or query results data.
- A connection component (ADO pages), all components of the data sets point to the specified database.
Data Control (Data Controls)
Delphi's data visualization components are usually located Standard page, but some have been modified for display and operation of data sets (table or query) the contents of the components. Controls the choice of how we would like to display information and how to allow users to browse (the operation - an increase or edit) data sets determined by the records. For example, DBEdit and DBMemo data sets used to display a single record. On the other hand, DBGrid is usually used to display the contents of the entire data set. Since all of the data visualization controls are all standard Windows controls the "copy" - with a number of additional attributes, then the establishment of a database has a certain function of the application should be very familiar with a related task (the translator added: and usually compared to the Windows task). All of the data visualization components to share the same attributes: Data Source (data source).
Data source (Data Source)
To put it simply, DataSource (data source) components to provide a mechanism for the data set data components and display components connected to data visualization. Typically, you need a data source components, data sets for each component with one or more connected data visualization controls.
In order to create an ADO-based applications, Delphi has provided data sets of four components: TAdoDataSet, TAdoTable, TAdoQuery and TAdoStoredProc. All the components used to obtain that data and change. Assembly can be adopted by all its ConnectionString (connection string) is directly connected to the ADO database (and the same Access database), or that they can share a connection. When connected through TAdoConnection components, the connection will be assigned an ADO Connection object to connect to the ADO database.
ADO connection (ADO Connection)
ADOConnection components used to create the database with the ADO connection. Although the ADO data sets for each component can be directly connected to the database, but we will continue to use ADOConnection components, because the component provides methods and properties for the activation of connections, direct access to ADO databases and processing services. In order to connect to the specified database, we use the ConnectionString (connection string) property.
Now, we know the relevant theory, is the time for action! The next step will be to establish a data form. Before you begin, open the database using Access and the database to add some "dummy" data for subsequent data manipulation, this is a good idea.