Syntax
| Success = SQL.RunRecordsetSite(SiteOrKeyID, Query, Records)
| |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description
| Executes a SELECT query on a named database connection from the server's Databases registry (the Databases tab of the CBBS/32 WebServer Configuration), independent of the current session connection, and returns the result as a disconnected read-only recordset.
The connection is looked up by its connection name (KeyID) or by its database name, case-insensitive. Exactly one registry entry must match: when two entries share the same database name, a lookup by that database name is ambiguous and the function returns False. A temporary connection is opened with the credentials managed in the server configuration; after the query completes the recordset is detached and the connection is closed again, so the returned recordset remains fully usable on its own.
This makes it possible for a script running on one session connection (for instance the central GENERAL connection) to read data from another site's database without maintaining its own logins, connection strings or configuration tables. The method was introduced for the Ask Tradium IQ role resolution, but is generic.
Remarks
The recordset is opened client-side as a static, read-only cursor (adUseClient / adOpenStatic / adLockReadOnly) and is detached from the connection before the function returns. It can therefore be read and scrolled freely, but not updated.
The temporary connection uses a connection timeout of 5 seconds and a command timeout of 10 seconds. An unreachable server therefore costs at most a few seconds and results in False, never in a hanging request or an error dialog. Connection failures do not affect the session connection.
| |||||||||||
See Also
| RunRecordset, other SQL.RunQueryxxxxxxxx functions, ADODB.Recordset.
| |||||||||||
Example
| Sub Main() Dim rsRec As ADODB.Recordset SQL.RunRecordset "Parameters", rsRec Do While Not rsRec.Eof Debug.Print rsRec(0), rsRec(1) rsRec.MoveNext Loop Set RsRec = Nothing End Sub ' Excel bestand uitlezen Sub Main() Dim rsRec As ADODB.Recordset SQL.RunRecordset "c:\mijn documenten\prijslijst.xls::Blad1", rsRec Do While Not rsRec.Eof Debug.Print rsRec(0), rsRec(1) rsRec.MoveNext Loop Set RsRec = Nothing End Sub | |||||||||||