Delphi Database Connection

Source: Internet
Author: User

Delphi Database Connection

A program needs a database connection engine to connect to the database.

In the process of using Delphi, I have used several Connection Methods to connect to Access, SqlServer, Oracle, IBM UDB, IBM AS/400...

1. BDE

This is one of the most commonly used methods of Delphi. You can add a BDE alias to the BDE Administration in the control panel. However, I am used to creating a BDE alias in SQL Explorer, because after the table is created, you can directly execute the table creation script.

You can right-click the alias list on the left of SQL Explorer, select the database type to be connected, and fill in necessary information in the connection parameters established by BDE later. Note, when you select a different database, the parameters on the right are slightly different. The differences between these parameters are caused by the different parameters required by different databases. For example, SqlServer needs to enter the server name, the name of the database.

BDE can connect all the databases I have used. Of course, some of them are connected through ODBC.

The BDE engine must be released when you publish a program. With InstallShield Express, you can easily do this.

The BDE alias can also be dynamically checked and created in the Delphi Program. I usually use the TSession component to Do It.

2. ODBC

This is Ms product.

If you establish a DSN connection in ODBC, your Delphi program still needs to use BDE to connect to it, but you do not need to manually create an alias in the previous step, BDE automatically creates aliases with the same name in BDE for all ODBC aliases, and it cannot be deleted unless you delete the odbc dsn.

In this way, the program connects to the database through BDE and ODBC.

I usually use this method when using Aceess earlier. Because there was no ADO at that time.

I also use this method when using ibm udb, because when using BDE for direct connection, the tables in the database cannot be enumerated in SQL Explorer, while ODBC can.

AS/400 can also be connected in this way...

Large relational databases provide ODBC drivers. When an ODBC source is created, its own configuration is called, and different databases are different.

ODBC source can also be written into the registry using code in the program to generate a DSN.

3. ADO

This is an upgraded version of ODBC, usually called mdac. The latest version I have used is 2.7, and it should be higher now. This is recommended when using the ms database SqlServer and Access, because it has been integrated into the operating system since win98 and provides all parameters in the form of connection strings, when releasing a system, you do not need to do anything other than the program.

It also provides some database-like connections, such as Excel.

It is worth mentioning that when a password is connected to Access, the connection character transmission generated by the Ado Wizard of Delphi has a Bug, and the generated password subitem is password = 'xxx '; but it cannot be connected. Manually change it to Jet Oledb password = 'xxx ).

4. DbExpress

This is the latest database engine provided by Borland. Currently, the driver is limited. I used it only to successfully test ibm udb. On the Internet, I can find the 3rd-party connection AS/400 driver.

It is an engine that provides one-way cursors. Borland is more efficient than BDE. And it will be developed in the future, and BDE updates will be stopped.

When using this method, DataSnap (formerly referred to as "das") technology should be used to provide two-way cursor applications, and the Data and Delta attributes of TClientDataset should be used to flexibly serialize Dataset, the Multi-Layer Loose coupling system is implemented.

3rd drive

I have never actually used any of these components. They are usually provided in the form of components, As I know, such As connecting Oracle Odac and connecting As/400 Delphi400...

Finally, if possible, we should try to use ADO to connect to the system and use DataSnap to operate local datasets to implement multi-layer systems.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.