Sort of, though Delphi's way of using tables is different than FoxPro's. In Delphi, you create a data module with ADO components pointing to the tables. Next, you create your client form, use the datamodule, place the visual components you need, and then connect them to the ADO components in your dataModule.
This design work saves you from writing code, for the database access is built into the connections between the components and there's no need to open the table in code.
However, if you want to do so, you can. Simply set properties of either your ADOTable and ADOConnection objects in the data module.
Drop a database component on a datamodule (found in the BDE tab) or the form you are showing and connect it to the database in question. Drop a SQL component on the datamodule. (I'll name it qryTableName) write SQL for qryTable like 'SELECT * FROM TABLE' or 'SELECT * FROM :TABLE' (I'll explain the difference in a minute)
If you choose the first one then you can use the following code:
With DataModule.qryTableName do
begin
SQL.Clear;
SQL.Add('SELECT * FROM ' + strTableName);
Active := True;
end;
The second method uses parameters and I have recently found that when running many queries against large databases this method can be much slower:
With DataModule.qryTableName do
begin
ParamByName('TABLE').AsString := strTableName;
Active := True;
end;
There are also some other configurations that have to be set to use this method. I would suggest the first method.
Then drop a DataSource component (Data Access tab - I'll name it dsTableName) set it's DataSet property to qryTableName. Set the DataSource property of the DBGrid to dsTableName. Then add the columns you need into the DBGrid and select the field from the query that you want to show in the grid.
It sounds complicated, but it's really easy. Mostly drop and drag, set some properties and you're good to go.
Hope that helps
Leslie
landrews@metrocourt.state.nm.us
There are 10 types of people in the world -
those who understand binary
and
those who don't!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.