To send back an ado recordset as text do this:
Private Function GetXML(ByVal strQuery As String) As String
On Error GoTo ErrorHandler
Dim rst As ADODB.Recordset
Dim stm As ADODB.Stream
Set rst = New ADODB.Recordset
Call rst.Open(strQuery, cnn, adOpenStatic, adLockReadOnly, adCmdText)
Set stm = New ADODB.Stream
rst.Save stm, adPersistXML
GetXML = stm.ReadText
stm.Close
rst.Close
Set stm = Nothing
Set rst = Nothing
ExitProcedure:
On Error Resume Next
Exit Function
ErrorHandler:
Select Case Err.Number
Case Else
'This shouldn't happen
Debug.Assert False
End Select
Resume ExitProcedure
End Function
Then call it like this:
xmlGetAccountingNumbers = GetXML("select * from tblAccountingNumbers order by AccountingNumber;")
|