Delphi的資料庫連接

1.dbexpress
2.ado
3.myodbc
4.3rd party object(Tmysql/zeros/MyDAC)

Tmysql
http://www.productivity.org/projects/tmysql/
看了介紹,Tmysql沒有使用TDatabase TQuery等,也不是使用BDE/ODBC
最後的版本在2002年的2月12日發佈
我用的是 Delhpi And C++ Builder 2009版的,不知道有沒有支援。

TDatabase是使用BDE(Borland Database Engine)
TQuery則是要設定ODBC資料來源(回想起當初出社會時,安裝軟體設定ODBC的痛苦)

MyDAC元件在網站是這麼介紹的
MySQL Data Aceess Componets,提供的物件蠻多的,請參考下圖
mydac_palette[1].jpg

下載頁在這裡,有免費版的可以下載
http://www.devart.com/mydac/download.html
重點是,有支援Delphi and C++ Builder 2009
而且,還有支援其他多種DB的連線
Oracle
SQL Server
InterBase
Firebird
PostgreSQK
(我又想去網路上找不是試用的版本了…唉宿命)
使用的是ADO.NET data provider, dbExpress drivers(不知道會不會連線成功)
首先,我沒有看到MyDAC的正式版或是破解版,所以咧,先用測試版跑看看。
在安裝的時候,出現了下面的訊息。
竟然找不到Hxds.dll
安裝MyDAC 5.8 for delphi and C++ Builder 2009,遺失Hxds.sll
經檢查,這是一隻微軟Help的元件,不過訊息上面說,這不是一個fatal(致命的錯誤),安裝會繼續完成。
這個錯誤訊息,一共出現了2次,我在想他是不是呼叫這件元件,來顯示他們的說明,anyway,不重要。
執行CodeGear RAD Studio 2009中的delphi 2009,出現了MyDAC的提示訊息,告訴我,我有60天的試用期。

哈哈~裝好了,就一個字爽
而且連接資料庫變的超簡單的

不過,看到他的價目表,嚇到我閃尿了!
標準 1人版 $129.95 USD金 群組版(4U) 299.95USD 網站版(同一間公司不限人數) $549.95 USD
專業 1人版 $199.95 USD金 群組版(4U) 499.95USD 網站版(同一間公司不限人數) $899.95 USD
其他的不敢看下去了(害我又想去找其他的版本了….)

* TMyConnection – lets you set up and control connections to MySQL database server
* TMyQuery – uses SQL statements to retrieve data from MySQL table or tables and supply it to one or more data-aware components through a TDataSource component and provides flexible data update functionality
* TMyTable – allows to retrieve and update data single table without writing SQL statement
* TMyStoredProc – executes stored procedures and functions
* TMyCommand – executes SQL statements and stored procedures, which do not return rowsets
* TMyScript – executes sequence of SQL statements
* TMyUpdateSQL – lets you tune update operations for a DataSet component
* TMyDataSource – provides an interface between a MyDAC dataset components and data-aware controls on a form
* TMySQLMonitor – allows to monitor dynamic SQL executing in MyDAC based applications
* TMyConnectDialog – allows you to build custom prompts for usernames, passwords, and servers
* TCRDBGrid – extends TDBGrid capabilities, provides visual access to filters and incremental search
* TVirtualTable – provides dataset functionality for data that has no real database connection
* MyDataAdapter – .NET component, uses TDataSet as data source for retrieving and saving data to System.Data.DataSet

MyDAC Professional Edition and MyDAC Developer Edition include the following additional components:

* TMyLoader – provides quick loading data to MySQL database
* TMyDump – serves to store a database or its parts as a script and also to restore database from received script
* TMyBackup – serves for backup copying specified tables on the server
* TMyServerControl – serves to control the server and execution of standard service tasks
* TMyEmbConnection – is used to establish connection to MySQL Embedded server
* TMyBuilder – serves to manage SQL Builder for MySQL Add-in
* TMyMetaData – retrieves metadata on specified SQL object
* TCRBatchMove – transfers data between all types of TDataSet descendants

另外,我找不到zeros的資料,網友說的不是很清楚。
The ZeosLib is a set of database components for MySQL, PostgreSQL, Interbase, Firebird, MS SQL, Sybase, Oracle and SQLite for Delphi, FreePascal/Lazarus, Kylix and C++ Builder.
網友寫錯了,是zeos,從zeoslib或sourceforge都可以下載
免費,開源,而且支援的好像也不少
只是不知道好不好用而以
剛才看了官網和下載完package之後
我失望了
因為目前6.X的版本,並不支援delphi 2009(12.0),只支援 Delphi V11
我再找看看其他delphi連接mysql的元件好了

剛才看到有網友用 mysql windows版的元件+dbExpress來連接Mysql,也許操作起來沒有像MyDAC這麼方便,不過,最少是不用錢的,而且MySQL元件,只要去下載Win 32的版本,可以取得,如果要做軟體發佈的時候,只要把libmySQL.dll copy到windows\system32下,就可以了,簡單方便許多。
有興趣的,可以參考這篇文
http://www.jackforfun.com/2008/11/delphi-2009-dbexpress-unicode-mysql-50.html?showComment=1247908318404#c6037813891210543481

Access violation at address in module 'libmysql.dll'. Read of address.
可是我照上面的試來來做
卻是有問題的,之前這台有灌過xampp和apps,不知道是不是元件的問題….唉,先測別的先