Chapter 4 Data Browsing and Navigation
Section 1 Setup and Connection
Welcome to Chapter 4 of the Free DB Delphi Tutorial! So far, this tutorial has explained how to connect to an access database and how to display graphical data in a database table. In the last chapter we discussed some "advanced" database programming techniques (translator's plus: relative to beginners) - now let's get back to the "for beginners" level.
This time, you'll learn how to create a form that allows you to browse data in a database table.
All the examples introduced in the previous chapters use several data-enabled components (ADOTable, DBGrid...) without fully explaining what functions each component is designed to achieve and how all data components are connected. Together. This chapter explains it.
Working together...
When developing ADO-based Delphi database applications, the components on the Data Controls page, ADO page, and Data Access page of the component palette allow our applications to read and write information from the database.
Every data-aware (ADO) Delphi form usually contains:
Data Controls
Delphi's data visualization components are usually located on the Standard page, but there are also components that have been modified to display and manipulate the contents of a data set (table or query). The choice of control is determined by how we want to display the information and how we want the user to browse (manipulate - add or edit) the records in the data set. For example, DBEdit and DBMemo are used to display individual records of a data set. DBGrid, on the other hand, is typically used to display the contents of an entire dataset. Since all data visualization controls are "copies" of standard Windows controls—with many additional properties—building a functional database application should be a related and familiar task. compared to usual Windows tasks). All data visual components share the same property: Data Source.
Data Source
Simply put, the DataSource component provides a mechanism to connect the dataset component to the data visualization component that displays the data. Typically, you need a data source component for each dataset component to connect to one or more data visualization controls.
Datasets
In order to create an ADO-based application, Delphi provides four data set components: TAdoDataSet, TAdoTable, TAdoQuery and TAdoStoredPRoc. All components are used to obtain, represent and change data. All components can connect directly to the ADO database (the same as the Access database) through its ConnectionString (connection string), or they can share a connection. When connecting through the TAdoConnection component, the connection will specify an ADO connection object to connect to the ADO database.
ADO Connection
The ADOConnection component is used to establish a connection with the ADO database. Although each ADO Dataset component can connect directly to the database, we will still use the ADOConnection component because it provides methods and properties for activating connections, direct access to the ADO database, and processing transactions. To connect to a specified database, we use the ConnectionString property.
Now that we know the theory, it’s time to act! The next step is to create a data form. Before starting, it is a good idea to open the database with Access and add some "dummy" data to the database for future data manipulation.