A program needs to connect to a database in the middle of a database connection
During the process of using Delphi, I have used several connection methods to connect access, SqlServer, Oracle, IBM UDB, IBM AS/400...
1.BDE
This is the way to use Delphi the most. Creating a BDE alias can be added in BDE Administration in the control panel. However, I am used to building it in SQL Explorer because after creation, you can directly execute the script for creating tables.
You can right-click the alias list on the left in SQL Explorer, select the type of database to connect to, and fill in the necessary information in the connection parameters established by the BDE later. Note that when you select a different database, the parameters on the right There are a few differences. The differences in these parameters are caused by different parameters required by different databases. For example, SqlServer needs to enter the name of the server and the name of the database.
BDE is able to connect to all the databases I have used, and of course some are connected through ODBC.
When publishing a program, the BDE engine must be released. Using InstallShield ExPRess can do this easily
The alias of BDE can also be dynamically checked and established 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, then your Delphi program still needs to use BDE to connect it, but at this time, you do not need to use the manual alias in the previous step to create an alias. BDE will automatically place all alias in ODBC in BDE Create an alias with the same name, and it cannot be deleted unless you delete the ODBC DSN.
In fact, the program is connected to the database through BDE and then through ODBC.
I usually use this method when using Acess in the early days. Because there was no ADO at that time.
Also when using IBM UDB, I use this way, because when using BDE to connect directly, the tables in the database will not be enumerated in SQL Explorer, and ODBC can.
AS/400 can also be connected in this way...
Large relational databases all provide ODBC drivers. When establishing an ODBC source, its own configuration will be called, and different databases are also different.
The ODBC source can also be written into the registry in the program with code to generate a DSN.
3.ADO
This is an upgraded version of ODBC, usually also called mdac, the latest version I have used is 2.7, and it should be higher now. When using ms database SqlServer and Access, it is recommended to use this thing because it has been integrated into the operating system since win98 and provides all parameters in the form of a connection string. When publishing the system, you do not need to do other than the program. Work.
It also provides connections including some class databases, such as Excel.
It is worth mentioning that when connecting password Access, the connection character transmission generated by Delphi's Ado wizard has a bug, and the generated password child is password='xxx'; this way, but this will not be connected, manually Change it to Jet Oledb password='xxx'; (It seems that's the case, I can't remember it).
4.DbExpress
This is the latest database engine provided by Borland. Currently, the drivers provided are limited. I have only successfully tested IBM UDB with it. You can find the drivers connected to AS/400 on the Internet.
It is an engine that provides one-way cursors, which Borland says is more efficient than BDE. And it will be developed later, while the update of BDE is stopped.
Usually when using this method, DataSnap (formerly known as Midas) technology should be used to provide bidirectional cursor applications, and the Data and Delta properties of TClientDataset are used to flexibly serialize the Dataset to implement a multi-layer loosely coupled system.
5. The drive of the third party
I have never used any of these in practice, usually provided in the form of components, as I know, such as the Odac connected to Oracle and the Delphi400 connected to As/400. . .
Finally, if possible, try to use ADO to connect to the system, and use DataSnap to operate local data sets to implement multi-layer systems.
A photo of a pole @Jindi.net