Example 47 : using the new capability to load data from MDB files

vcl grid MDB files

2 New methods enable loading of Access tables in the grid : LoadFromMDBSQL and LoadFromMDBTable. Both methods use ADO. Note that this imposes no requirements at all for grids that do not use this feature on the availability of ADO on the target machine.


LoadFromMDBTable(Filename, Table:string);

This method loads the selcted table from the MDB file into TAdvStringGrid. From there, it can be printed, exported to HTML, CSV etc ..

LoadFromMDBSQL(Filename, SQL:string);

This method allows using an Access compatible SQL statement to retrieve the data from an Access file. Suppose the MDB file has a table CARS and only the cars from this table with 6 or more cylinders need to be loaded into the grid. In this case you can write :

AdvStringGrid1.LoadFromMDBSQL('mydb.mdb','SELECT * FROM CARS WHERE CYL >= 6');

Delphi project & source files for downloading included in the main demos distribution for Delphi.