全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:5884
推到 Plurk!
推到 Facebook!

使用dbExpress ODBC 來連結 PostgreSQL for 32 / 64 bit

 
GrandRURU
站務副站長


發表:240
回覆:1680
積分:1874
註冊:2005-06-21

發送簡訊給我
#1 引用回覆 回覆 發表時間:2012-03-25 20:33:37 IP:182.235.xxx.xxx 未訂閱
如果使用ADO,疑於先天架構的限制,只能使用到32bit的驅動程式
現在,Delphi XE2 在 64bit 環境下,有新的選擇:dbExpress ODBC

詳情請參閱:
connecting-to-postgresql-through-dbexpress-odbc-driver

以下為原文轉載:

C Builder XE2 introduce the new dbExpress ODBC driver, which enable FireMonkey and VCL applications to connect to any database that provides a ODBC driver.
In order to show how it works, I created a FireMonkey project sample that connect to a PostgreSQL database.
As first step, you must install the PostgreSQL ODBC driver on the machine that will run the application. Second, applications compiled as 32-bit, requires the
  • For 32-bit applications use c:\Windows\SysWOW64\odbcad32.exe
  • For 64-bit applications use o c:\Windows\system32\odbcad32.exe
  • Instructions for windows 32-bit
    • Use c:\Windows\system32\odbcad32.exe
    The next step is to create an dbExpress ODBC alias on Data Explorer, where the Database Name parameter is the name of the Data Source created earlier, in my example the Data Source is called PostgreSQL35W. The database, username and password was already defined in the Data Source, but you can override the username and password parameters through the SQLConnection.

    Assuming you already know how to use the SQLConnection, DataSetProvider and ClientDataSet or SimpleDataSet ,and DataSource components, just connect all the components as you usually do. The SQLConnection will look like this:
      object SQLConnection1: TSQLConnection
        ConnectionName = 'PostgreSQLOdbc'
        DriverName = 'ODBC'
        LoginPrompt = False
        Params.Strings = (
          'drivername=ODBC'
          'Database=PostgreSQL35W')
      end

    You can use the dbExpress framework when connected to a database through dbExpress ODBC driver. In XE2 the ODBC driver is compatible with Windows, we are evaluating the possibility to support this driver on Mac.
    The figure below shows the FireMonkey application connected to PostgreSQL via dbExpress ODBC driver. Now you can connect to any other other database not supported natively by dbExpress.

    Download the source code here.
    系統時間:2024-11-21 16:37:21
    聯絡我們 | Delphi K.Top討論版
    本站聲明
    1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
    2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
    3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!