HOWTO: Send a Data Recordset Using MSMQ Message Body

Last reviewed: March 11, 1998
Article ID: Q179575
The information in this article applies to:
  • Microsoft Message Queue Server version 1.0

SUMMARY

Using Microsoft Message Queue Server (MSMQ) and Microsoft Remote Data Service (RDS), you can send and receive a data recordset using MSMQ message body.

MORE INFORMATION

Follow these steps to run the code example below:

  1. Install Remote Data Service (RDS) 1.5 from this Web address:

          http://www.microsoft.com/data/rds/
    

  2. Add references to Microsoft Message Queue Server (MSMQ), the ActiveX Data Objects (ADO) 1.5 Object Library, and Remote Data Service (RDS) Object Libraries in your Visual Basic project. The sample opens a connection to the SQL Server pubs database on your computer. You can modify the code to use other databases.

          Private Sub Form_Load()
          Dim rs As ADOR.Recordset
          Dim sql As String
          Dim dataFactory As Object
    

          Dim qinfo As New MSMQQueueInfo
          Dim mSend As New MSMQMessage
          Dim mReceive As MSMQMessage
          Dim qSend As MSMQQueue
          Dim qReceive As MSMQQueue
    

          qinfo.PathName = ".\RecordsetQ"
          qinfo.Label = "My Recordset Queue"
          On Error Resume Next  ' ignore if the queue already exists
          qinfo.Create
    

          Set qSend = qinfo.Open(MQ_SEND_ACCESS, MQ_DENY_NONE)
    

          Set dataFactory = CreateObject("AdvancedDataFactory")
    

          sql = "select * from authors"
          Set rs = dataFactory.query("driver={SQL
          Server};SERVER=.;database=pubs;uid=sa;pwd=", sql)
    

          mSend.Label = "Testing Recordset"
          mSend.Body = rs
          mSend.Send qSend
          qSend.Close
    

          MsgBox "Message sent with Recordset"
    

          Set qReceive = qinfo.Open(MQ_RECEIVE_ACCESS, MQ_DENY_NONE)
    

          Set mReceive = qReceive.Receive
          Set rs = mReceive.Body
          Debug.Print rs(0) ' print column 1
          Debug.Print rs(1) ' print column 2
          Debug.Print rs(2) ' print column 3
          rs.movenext
          Debug.Print rs(0) ' print column 1
          Debug.Print rs(1) ' print column 2
          Debug.Print rs(2) ' print column 3
    

          End Sub
    

REFERENCES

Microsoft Message Queue Server SDK Help.

Remote Data Service (RDS) documentation located at this Web address:

   http://www.microsoft.com/data/rds/

Keywords          : kbcode MQProg
Version           : WINNT:1.0
Platform          : winnt
Hardware          : ALPHA x86
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 11, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.