Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to access a database like ACCESS or SYBASE in BUILDER

How to access a database like ACCESS or SYBASE in BUILDER

by  wimvanherp  Posted    (Edited  )
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 :

BUILDER Application -->Grid Component (DataSource) -->TdataSourceComponent(DataSet) ->TtableComponent (DatabaseName,TableName)--> BDEngine--->ODBCdriver ûSpecific Database--->Database

2) MAKE THE LINK TO THE DATABASE

- 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.






Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top