Syntax
| AI.AttachRecordset(Handle As Long, rs As Object, [Caption As String], [Scope As AIRecordsetScope], [MaxRows As Long], [Columns As Variant]) As Boolean
| ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description
| Attaches the data of an ADODB recordset to a conversation handle, so the model can analyse it. The recordset is serialised at the moment of the call — a snapshot, independent of the cursor position and of the query that produced it. The cursor of the macro's own recordset is left untouched.
Call this before Ask, on a handle from NewConversation. The return value is True on success, or False on a validation error.
At most one recordset may be attached per handle. A second call on the same handle fails with aiErrInvalidRequest. A handle may carry both files and one recordset at the same time.
| ||||||||||||||||||||||||
See Also
|
| ||||||||||||||||||||||||
Example
| Dim rs As ADODB.Recordset
SQL.RunRecordset "SELECT * FROM Relaties WITH (READUNCOMMITTED) " & _
"WHERE Admin = 1 AND Soort = 'K'", _
rs, adOpenKeyset, adLockReadOnly, adUseServer
Dim aiHnd As Long
aiHnd = AI.NewConversation(aiGeneral)
If AI.AttachRecordset(aiHnd, rs, "Customers admin 1", aiRsAllRows, 1000, _
Array("Postcode", "Plaats")) Then
aiHnd = AI.Ask("Which towns have the most customers? Give a top 5.", , aiHnd)
End If
|