Opening a Connection Using TDataBase
As with all database connection components, to connect to a database using TDatabase, you set the Connected property to True or call the Open method. This process is described in Connecting to a Database Server. Once a database connection is established, the connection is maintained as long as there is at least one active dataset. When there are no more active datasets, the connection is dropped, unless the database component's KeepConnection property is True.
When you connect to a remote database server from an application, the application uses the BDE and the Embarcadero SQL Links driver to establish the connection. (The BDE can also communicate with an ODBC driver that you supply.) You need to configure the SQL Links or ODBC driver for your application prior to making the connection. SQL Links and ODBC parameters are stored in the Params property of a database component. For information about SQL Links parameters, see the online SQL Links User's Guide. To edit the Params property, see Setting BDE Alias Parameters.
Working with network protocols
As part of configuring the appropriate SQL Links or ODBC driver, you may need to specify the network protocol used by the server, such as SPX/IPX or TCP/IP, depending on the driver's configuration options. In most cases, network protocol configuration is handled using a server's client setup software. For ODBC it may also be necessary to check the driver setup using the ODBC driver manager.
Establishing an initial connection between client and server can be problematic. The following troubleshooting checklist should be helpful if you encounter difficulties:
- Is your server's client-side connection properly configured?
- Are the DLLs for your connection and database drivers in the search path?
- If you are using TCP/IP:
- Is your TCP/IP communications software installed? Is the proper WINSOCK.DLL installed?
- Is the server's IP address registered in the client's HOSTS file?
- Is the Domain Name Services (DNS) properly configured?
- Can you ping the server?
For more troubleshooting information, see the online SQL Links User's Guide and your server documentation.
An application can use ODBC data sources (for example, Btrieve). An ODBC driver connection requires:
- A vendor-supplied ODBC driver.
- The Microsoft ODBC Driver Manager.