共用方式為


撰寫您自己的自定義處理程式

如果您是想要預設 RDS 支援的 IIS 伺服器管理員,則可以撰寫自己的處理程式,但更能控制使用者要求和訪問許可權。

MSDFMAP.Handler 會實作 IDataFactoryHandler 介面。

重要

從 Windows 8 和 Windows Server 2012 開始,RDS 伺服器元件已不再包含在 Windows 作業系統中(如需詳細資訊,請參閱 Windows 8 和 Windows Server 2012 兼容性 Cookbook)。 RDS 用戶端元件將在未來的 Windows 版本中移除。 請避免在新的開發工作中使用此功能,並計劃修改目前使用此功能的應用程式。 使用 RDS 的應用程式應該移至 WCF Data Service

IDataFactoryHandler 介面

這個介面有兩種方法,GetRecordset重新連線。 這兩種方法都需要將 CursorLocation 屬性設定為 adUseClient

這兩種方法都會接受自變數,這些自變數會出現在 「Handler=」 關鍵詞中的第一個逗號後面。 例如,"Handler=progid,arg1,arg2;" 會傳遞 "arg1,arg2"的自變數字串,而 "Handler=progid" 會傳遞 null 自變數。

GetRecordset 方法

此方法會使用提供的自變數來查詢數據源,並建立新的 Recordset 物件。 Recordset 必須使用 adLockBatchOptimistic 開啟,且不得以異步方式開啟。

爭論

conn 連接字串。

args 處理程式的自變數。

查詢 用於進行查詢的命令文字。

ppRS 應該傳回 Recordset 的指標。

重新連線方法

此方法會更新數據源。 它會建立新的 Connection 物件,並附加指定的 Recordset

辯論

conn 連接字串。

args 處理程式的自變數。

pRS A Recordset 物件。

msdfhdl.idl

這是出現在 msdfhdl.idl 檔案中 IDataFactoryHandler 的介面定義。

[  
  uuid(D80DE8B3-0001-11d1-91E6-00C04FBBBFB3),  
  version(1.0)  
]  
library MSDFHDL  
{  
    importlib("stdole32.tlb");  
    importlib("stdole2.tlb");  
  
    // TLib : Microsoft ActiveX Data Objects 2.0 Library  
    // {00000200-0000-0010-8000-00AA006D2EA4}  
    #ifdef IMPLIB  
    importlib("implib\\x86\\release\\ado\\msado15.dll");  
    #else  
    importlib("msado20.dll");  
    #endif  
  
    [  
      odl,  
      uuid(D80DE8B5-0001-11d1-91E6-00C04FBBBFB3),  
      version(1.0)  
    ]  
    interface IDataFactoryHandler : IUnknown  
    {  
HRESULT _stdcall GetRecordset(  
      [in] BSTR conn,  
      [in] BSTR args,  
      [in] BSTR query,  
      [out, retval] _Recordset **ppRS);  
  
// DataFactory will use the ActiveConnection property  
// on the Recordset after calling Reconnect.  
   HRESULT _stdcall Reconnect(  
      [in] BSTR conn,  
      [in] BSTR args,  
      [in] _Recordset *pRS);  
    };  
};  

另請參閱

自定義檔案連接區段
自定義檔案記錄區段
自訂檔案 SQL 區段
自訂檔案用戶列表區段
DataFactory 自定義
必要的客戶端設定
瞭解自定義檔案