![]() ![]() The SQL used in a ADOQuery component must be acceptable to the ADO driver in use. It is most often used to execute DDL commands or to execute a stored procedure (even though you should use the TADOStoredProc for such tasks) that does not return a result set. Note: even though executing commands using the ADOQuery component is possible, the ADOCommand component is more appropriate for this purpose. The most common statement, however, is the SELECT statement, which produces a view similar to that available using a Table component. These SQL statements can either be DDL (Data Definition Language) statements such as CREATE TABLE, ALTER INDEX, and so forth, or they can be DML (Data Manipulation Language) statements, such as SELECT, UPDATE, and DELETE. The TADOQuery component provides Delphi developers the ability to fetch data from one or multiple tables from an ADO database using SQL. In practice is much more simpler than my description here.In this chapter of the free database course for Delphi beginners - focus on ADO, we'll look at how you can take advantage of the TADOQuery component to boost your ADO-Delphi productivity. For the specific column of the lookup field (COUNTRYLOOK), instead of using the 1:1 mapping you can put in the 4th line of your query ORDER BY CO.NAME. When one clicks on the Title Header you can change the query by adding in the 4th line an ORDER BY. ![]() Then you'll display in your TDBGrid (as columns) only the ID, NAME and the desired lookup field which you already have (let's call it COUNTRYLOOK). (Not tested but I think that you got the idea) Then you can have the following query in the dataset which is linked to the TDBGrid: SELECT C.ID, C.NAME, C.COUNTRYID, CO.NAME Let's suppose that you have the following tables: (PK means Primary Key) Contacts ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |