撰寫您自己的自訂處理常式

如果您是想要預設 RDS 支援,卻希望能控制更多使用者要求和存取權限的 IIS 伺服器系統管理員,您可能會想要撰寫自己的處理常式。

MSDFMAP.Handler 會實作 IDataFactoryHandler 介面。

重要

從 Windows 8 和 Windows Server 2012 開始,Windows 作業系統中不再包含 RDS 伺服器元件 (請參閱 Windows 8 和 Windows Server 2012 相容性逐步指南 (英文) 以取得詳細資料)。 未來的 Windows 版本將移除 RDS 用戶端元件。 請避免在新的開發工作中使用這項功能,並規劃修改目前使用這項功能的應用程式。 使用 RDS 的應用程式應該移轉至 WCF 資料服務

IDataFactoryHandler 介面

此介面有兩種方法:GetRecordsetReconnect。 這兩種方法都要求將 CursorLocation 屬性設定為 adUseClient

這兩種方法都會採用出現在 "Handler=" 關鍵字中第一個逗號後面的引數。 例如,"Handler=progid,arg1,arg2;" 會傳遞 "arg1,arg2" 的引數字串,而 "Handler=progid" 會傳遞 null 引數。

GetRecordset 方法

這個方法會查詢資料來源,並使用所提供的引數建立新的 Recordset 物件。 Recordset 必須使用 adLockBatchOptimistic 開啟,而且不得以非同步方式開啟。

引數

conn 連接字串。

args 處理常式的引數。

query 執行查詢的命令文字。

ppRS 應該傳回 Recordset 的指標。

Reconnect 方法

這個方法會更新資料來源。 它會建立新的 Connection 物件,並附加指定的 Recordset

引數

conn 連接字串。

args 處理常式的引數。

pRS 一個 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);  
    };  
};  

另請參閱

自訂檔案 Connect 區段
自訂檔案 Logs 區段
自訂檔案 SQL 區段
自訂檔案 UserList 區段
DataFactory 自訂
必要用戶端設定
了解自訂檔案