Handler Property Example (VB)

Microsoft ActiveX Data Objects (ADO)

Handler Property Example (VB)

This example demonstrates the RDS DataControl object Handler property. (See DataFactory Customization for more details.)

Assume that the following sections in the parameter file, MSDFMAP.INI, are located on the server:

[connect AuthorDataBase]
Access=ReadWrite
Connect="DSN=Pubs"
[sql AuthorById]
SQL="SELECT * FROM Authors WHERE au_id = ?"

Your code looks like the following. The command assigned to the SQL property will match the AuthorById identifier, and retrieve a row for author, Michael O'Leary. Although the Connect property in your code specifies the Northwind data source, that data source will be overwritten by the MSDFMAP.INI connect section. The DataControl object Recordset property is assigned to a disconnected Recordset object purely as a coding convenience.

Public Sub Main()
    HandlerX
End Sub

Public Sub HandlerX()
Dim dc As New DataControl
Dim rst As ADODB.Recordset

dc.Handler = "MSDFMAP.Handler"
dc.Server = "http://YourServer"
dc.Connect = "Data Source=Northwind"
dc.SQL = "AuthorById(267-41-2394)"
dc.Refresh                  'Retrieve the record
Set rst = dc.Recordset      'Use another Recordset as a convenience
Debug.Print "Author is '" & rst!au_fname & " " & rst!au_lname & "'"

End Sub