Handler Property Example (VB)

Microsoft ActiveX Data Objects (ADO)

RDS 2.5 API Reference

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 will retrieve a row for author Michael O'Leary. The DataControl object Recordset property is assigned to a disconnected Recordset object purely as a coding convenience.

'BeginHandlerVB

Public Sub Main()

On Error GoTo ErrorHandler

Dim dc As New DataControl

Dim rst As ADODB.Recordset

dc.Handler = "MSDFMAP.Handler"

dc.ExecuteOptions = 1

dc.FetchOptions = 1

dc.Server = "http://MyServer"

dc.Connect = "Data Source=AuthorDataBase"

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 & "'"

' clean up

If rst.State = adStateOpen Then rst.Close

Set rst = Nothing

Set dc = Nothing

Exit Sub

ErrorHandler:

' clean up

If Not rst Is Nothing Then

If rst.State = adStateOpen Then rst.Close

End If

Set rst = Nothing

Set dc = Nothing

If Err <> 0 Then

MsgBox Err.Source & "-->" & Err.Description, , "Error"

End If

End Sub

'EndHandlerVB

See Also

DataControl Object (RDS) | Handler Property (RDS)

© 1998-2003 Microsoft Corporation. All rights reserved.