Writing Your Own Customized Handler

   

You may want to write your own Handler if you are an IIS server administrator who wants the default RDS support, but more control over user requests and access rights.

The MSDFMAP.Handler implements the IDataFactoryHandler interface.

IDataFactoryHandler Interface

This interface has two methods, GetRecordset and Reconnect. Both methods require the CursorLocation property be set to adUseClient.

Both methods take arguments that appear after the first comma in the "Handler=" keyword. For example, "Handler=progid,arg1,arg2;" will pass an argument string of "arg1,arg2", and "Handler=progid" will pass a NULL argument.

GetRecordset Method

This function is used to query the data source and create a new Recordset object using the arguments provided. The Recordset must be opened with adLockBatchOptimistic, and must not be opened asynchronously.

Syntax

conn   The connection string.

args   Arguments for the handler.

query   The command text for making a query.

ppRS   Pointer where the Recordset should be returned.

Reconnect Method

This function is used to update the data source. It will create a new Connection object and attach the given Recordset.

Syntax

conn   The connection string.

args   Arguments for the handler.

pRS   A Recordset object.

msdfhdl.idl

This is the interface definition for IdataFactoryHandler that appears in the msdfhdl.idl file.

[
  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);
    };
};