In the previous article, we discussed how to use the ADO components and we created an example program using an ADOTable component. In this article we are going to discuss the ADOQuery component and how it can help us deal with data manipulation in an ADO database.
SQL is an acronym for Structured Query Language. It is a language that is used to interrogate a database. SQL gives us the flexibility to retrieve information in a variety of ways from a database. It takes the form of a command language that lets you select, insert, update and find the location of data, and so forth.
ADOQuery has a SQL property (as you will see later on in the article) that is used to store SQL statements. Queries can be divided into two categories: those that produce results, such as the SELECT statement, and those that donít such as the DELETE or INSERT statements. They are also executed in different ways:
Query.open is used to execute those that produce results.
Query.execSQL is used to execute those that donít produce results.
The SQL statements can be either static or dynamic, that is, they can be set at design time or include parameters (Query.Params) that vary at run time. Using parameterized queries is very flexible, because you can change a user's view of and access to data on the fly at run time. This gives you more flexibility to retrieve only the exact data that you require, instead of everything in the database, such as when using an ADOTable component. It is also worth mentioning that you can do everything that an ADOTable does and more with an ADOQuery dataset.