C++builder has the outstanding database network development function, may access each kind of relational database, provides the efficient data aware component and the data access component, it not only can provide the client program for the C/s structure, but also may develop the application server program, realizes the Multi-layer database application architecture, VFP database is the best choice for network development.
VFP database system has two ways to establish a data table, one is to establish a free table compatible with the FoxPro, the other is to establish a database, the database contains data tables and relationships, so in C + + Builder use VFP database also exist in two ways, namely a way is directly called VFP free table, Another way is to use ODBC to invoke VFP database, this article will be illustrated separately.
Direct Call VFP Free table
1. Set up data table:
The data table structure is as follows:
字段名 类型 宽度
档案名称 字符型 100
存放名 字符型 2
2. Create form Form1:
Place controls such as Ttable, Tdatasource, TDBGrid, Tdbnavigator, and so on.
To set the Ttable control properties:
Tabletype is set as Ttfoxpro;
TableName is set as WJK.DBF;
The active setting is true.
Connect controls such as Tdatasource, TDBGrid, Tdbnavigator, and so on.
modifying, deleting, adding, and storing content can be implemented by Tdbnavigator controls or written programmatically.
Calling VFP database through ODBC
1. Access to the panel of ODBC data source to connect VFP database.
2. In the C++builder:
Place controls such as Tdatabase, Ttable, Tdatasource, TDBGrid, Tdbnavigator, and so on.
To set the Tdatabase control properties:
AliasName set to ODBC in the connection of the VFP database name;
DatabaseName is set to the user-defined database name in C + + Builder;
Params content is set to null;
Loginprompt to false;
Connected is true to connect to the database.
Other component setup methods are similar to free tables.
In the example above, direct call VFP free table speed, method simple, easy to operate, but when there is a composite index in the table will be called failure, you need to delete the composite index from the original table, before you can call from C + + Builder, and through ODBC call VFP database speed is not directly call fast, setting is more complex than free table, but preserves the original definition of the database.