Delphi Connection Database

Source: Internet
Author: User
Tags dsn odbc

A program connects to a database requires a database connection engine

In the process of using Delphi, I have used several connection ways to connect ACCESS,SQLSERVER,ORACLE,IBM udb,ibm as/400 ...

1.BDE

This is the most common way to use Delphi to create a BDE alias that can be added to the BDE Administration in Control Panel, but I'm used to creating it in SQL Explorer because it's a straightforward script to build the table.

You can right-click on the left-hand list in SQL Explorer and select the type of database you want to connect to, and then fill in the necessary information in the connection parameters that you BDE, and note that when you select a different database, the parameters on the right side are slightly different. The differences in these parameters are due to the different parameters required by the different databases, for example, SQL Server needs to enter the names of the servers and the names of the databases.

BDE is able to connect all the databases I have used, and of course some are connected through ODBC.

When you publish a program, you must publish the BDE engine. It's easy to do this thing with InstallShield Express.

BDE alias can also be in the Delphi program Dynamic Inspection has no and established. I usually use the TSession component to do It.

2.ODBC

This is the product of Ms.

If you set up a DSN connection in ODBC, then your Delphi program still needs to use BDE to connect it, but at this time do not need to use the manual establishment alias in the previous step, BDE will automatically create the alias of the same name in the BDE for all aliases in ODBC, and it will not be erased, Unless you delete the ODBC DSN.

This approach is actually the program through the BDE, and then through ODBC, to connect to the database.

I usually use this approach in the early days when using aceess. Because there was no ADO at that time.

Also in the case of IBM UDB, I use this approach because the tables in the database cannot be enumerated in SQL Explorer when using BDE Direct connection, and ODBC can.

As/400 can also use this method to connect ...

Large relational databases provide ODBC-driven. When an ODBC source is established, its own configuration is invoked, and the different databases are different.

ODBC sources can also generate a DSN in the program's code to write to the registry.

3.ADO

This is an upgraded version of ODBC, usually called MDAC, and the latest version I've used is 2.7 and should be higher now. This is recommended when using MS's database sqlserver,access, since he is integrated into the operating system from Win98 and provides all parameters in the form of a connection string, and does not need to do other work outside the program when publishing the system.

It also provides connections including some class databases, such as Excel.

It is worth mentioning is connected with password access, the Delphi ADO Wizard generated by the connection word Fu is a bug, its generated password child is password= ' xxx '; but this will not connect, manually convert it to Jet OLE DB password= ' xxx ';(seems to be so, not remember clearly.

4.DbExpress

This is the latest database engine provided by Borland, and currently offers a limited drive, and I have only successfully tested IBM UDB and can find 3rd party connection as/400 on the web.

It is an engine that provides a one-way cursor, and Borland says it is more efficient compared to BDE. and will develop it later, while stopping the renewal of the BDE.

Often in this way, Datasnap (formerly known as Midas) technique should be used to provide bidirectional cursor applications, and the TClientDataSet Data,delta attribute is used to serialize the dataset flexibly, and multilayer loosely coupled systems are implemented.

5.3rd-Party drivers

None of these I have ever used in practice, usually in the form of components, I know such as connecting Oracle ODAC, connecting as/400 Delphi400 ...

Finally, if possible, you should use ADO to connect the system as much as possible, and use Datasnap to manipulate the local dataset to implement multi-tier 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.