HOWTO: Send a Data Recordset Using Microsoft Message Queue Server Message Body

ID: Q179575


The information in this article applies to:


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 Microsoft Data Access Components (MDAC) 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 RDS as Object

      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 RDS = CreateObject("RDS.DataSpace")


      Set dataFactory = RDS.CreateObject("RDSServer.DataFactory","localhost")


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

      mSend.Label = "Testing Recordset"
      Set 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/

Additional query words: kbdse


Keywords          : kbcode kbRDS150 kbRDS200 
Version           : WINDOWS:1.0,2.0; winnt:1.0
Platform          : WINDOWS winnt 
Issue type        : kbhowto 

Last Reviewed: February 2, 1999