HOW TO ACCESS OTHER DATABASES (ACCESS,SYBASE à) WITH BUILDER
1) CONCEPTS
To access a database, the manufacturer of the database delivers a driver with wich his programs can work with the database. This driver is the interface between the program and the database. To allow other programs to have access to this database there is an interface called ODBC: Open DataBase Connectivity. The manufacturer also delivers an ODBC-driver so that everyone can talk to his database via the ODBC-protocol wich is supposed to be universal.
In C++ Builder the interface to databases is done via the Borland Database Engine (BDE), this is a supplementary layer that can talk to databases via ODBC or directly to the database if you have the interface program to the specific driver of this database.
A way to display a table of a database in Builder is :
- Make an ODBC ûlink to the database (IÆll take the example of ACCESS). In configuration-screen choose ODBC--->System DSN (this allows you to make an ODBC Alias for all the users on this computer)-->ADD-->Microsoft Access Driver--->Confirm (I donÆt know the exact name of the button because IÆm working on a Dutch Version). Then you fill in a DATA SOURCE NAME and you select your Acces Database . The DATA SOURCE NAME is the ODBC Alias wich will point to the right ACCESS-ODBC-driver and to the database youÆve choosen. If you press OK youÆll return to the main window and you see that you alias is added to the window.
- Open DataBase Explorer from Borland and you will see that you new ODBC- alias is added to the databases, Borland has made a new BDE_alias to the ODBC alias and if you wish you can rename this BDE-alias but it is not necessary.
- Open a project in Builder and put a TTable component, TDataSource component and a DBgrid component on your form. The Ttable component makes the connection to your BDE-alias via the property Database Name, use the drop down menu to choose your alias, choose also wich table of your Database you want to acces in the TableName Property. The Datasource component makes the connection between the Ttable component and the grid wich will display the data. In the DataSource component choose the name of the Ttable component (f.i. Table1) in the DataSet Property. In the Grid choose the DataSource component name (f.i. DataSource1). Set the Active-property of the Table1 to true and the grid will display the contents of the choosen table of the database.
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.