2021/05/03

How to embedded DBX DLL for Deployment in project, take Devart Driver as an example.


Table of Contents


English Version

Studying Devart dbExpress driver, readme file for SQL Server :

Users of dbExpress driver for SQL Server with Source Code can embed the driver into the application directly. For information on how to do this refer to Borland documentation.

This sentence mainly explains that Devart company can use certain mechanisms to make the existence of DBX Dll unnecessary when deploying the project, for example: dbexpsda40.dll and so on.

No need to deploy the advantages of DBX DLL

Some DBX Drivers need to install the DB Client, but Devart provides a [Direct Connection] mode, in which the database access components can be directly connected to the DB via TCP without the DB Client. In addition to omitting the conversion of DB Client, there is no need for additional deployment of DBX DLL settings, which can effectively eliminate potential system configuration problems and save time for publishing system configuration.

Disadvantages of not needing to deploy DBX DLL


Although there is no need to deploy DLL, based on the principle of equivalent exchange, the capacity of the DLL will be filled into the EXE we want to deployment, which will cause the execution file to become larger - it grows about 487 Kb.

Prerequisites for use


You need to purchase [version with source code] first, and exchange for knowledge achievements with a small price, I think it is worth it!

How to

After the purchase of the [Include source code version] condition is established, and you only need to add the [DbxSdaDriverLoader] unit to the project, supplemented by the following code, to achieve the goal of [No DBX DLL required]:

uses
  Data.DB, Data.SqlExpr, DBXDevartSQLServer, DbxSdaDriverLoader;

...

procedure TForm1.Button1Click(Sender: TObject);
begin
  SQLConnection1.DriverName := 'DevartSQLServerDirectBuiltin';
  SQLConnection1.LibraryName := 'dbexpsda41.dll';
  SQLConnection1.VendorLib := '';  
  SQLConnection1.GetDriverFunc := 'getSQLDriverSQLServerDirect';
  SQLConnection1.Params.Values['OS Authentication'] := 'False';
  SQLConnection1.Params.Values['HostName'] := 'Host';  
  SQLConnection1.Params.Values['User_Name'] := 'sa';
  SQLConnection1.Params.Values['Password'] := '';
  SQLConnection1.Params.Values['Database'] := 'Database';
  SQLConnection1.LoginPrompt := False;
  SQLConnection1.Connected := True;
end;


Summary

Developers using DBX don’t actually need to rush to replace components. Sometimes spend some cost, can bring more value.

The above information is shared with you!

================================================================

中文版

在研究 Devart dbExpress driver for SQL Server 的 Readme 檔案時,我發現了一句古代文字:

Users of dbExpress driver for SQL Server with Source Code can embed the driver into the application directly. For information on how to do this refer to Borland documentation.
這句話主要在說明 Devart 它可以利用某些機制,使佈署專案時可以不需要 DBX Dll 的存在,例如:dbexpsda40.dll 等。

不需佈署 DBX DLL 的優點

有些 DBX Driver 需要安裝 DB Client,但 Devart 提供【直接連接】模式,在此模式下可以讓資料庫存取元件在不用 DB Client 的場合下透過 TCP 直接連接 DB。除了少掉 DB Client 的轉換外,更不需要額外佈署 DBX DLL 的設定,可以有效排除潛在的系統設定問題和節省發佈系統的設定時間。

不需佈署 DBX DLL 的缺點


雖說不用佈署 DLL,但基於等價交換原則,DLL 的容量會填充到我們欲發佈的 EXE 上面,進而造成執行檔變大的情形 -- 大約成長 487 Kb 左右。

使用前提

方便部署的前提為【購買含原始碼版本】,用少許代價換取知識成果,我認為值得!

如何設計

在使用前提【購買含原始碼版本】條件成立下,之後只需在專案中加入【DbxSdaDriverLoader】單元,並輔以底下程式碼,便能達成【不需 DBX DLL】的目標:


uses
  Data.DB, Data.SqlExpr, DBXDevartSQLServer, DbxSdaDriverLoader;

...

procedure TForm1.Button1Click(Sender: TObject);
begin
  SQLConnection1.DriverName := 'DevartSQLServerDirectBuiltin';
  SQLConnection1.LibraryName := 'dbexpsda41.dll';
  SQLConnection1.VendorLib := '';  
  SQLConnection1.GetDriverFunc := 'getSQLDriverSQLServerDirect';
  SQLConnection1.Params.Values['OS Authentication'] := 'False';
  SQLConnection1.Params.Values['HostName'] := 'Host';  
  SQLConnection1.Params.Values['User_Name'] := 'sa';
  SQLConnection1.Params.Values['Password'] := '';
  SQLConnection1.Params.Values['Database'] := 'Database';
  SQLConnection1.LoginPrompt := False;
  SQLConnection1.Connected := True;
end;


總結

使用 DBX 的開發者其實不需要急著更換元件,有時使用更好的 Driver 也能夠達到【花得更少,用得更好】的目標,用少許的金錢所帶來的經濟效益遠超乎想像。


以上資訊和你分享!


See also

沒有留言:

張貼留言