HOWTO: Send a Data Recordset Using Microsoft Message Queue Server Message Body
ID: Q179575
|
The information in this article applies to:
-
Microsoft Message Queue Server version 1.0
-
Remote Data Service for ADO versions 1.5, 2.0, 2.1 SP2
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:
- Install Microsoft Data Access Components (MDAC) from this Web address:
http://www.microsoft.com/data/ado/rds
- Add references to Microsoft Message Queue Server (MSMQ), the ActiveX
Data Objects (ADO) 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 rsSend As ADOR.Recordset
Dim rsReceive 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"
' ignore if the queue already exists
On Error Resume Next
qinfo.Create
On Error GoTo 0
Set qSend = qinfo.Open(MQ_SEND_ACCESS, MQ_DENY_NONE)
Set RDS = CreateObject("RDS.DataSpace")
Set dataFactory = RDS.CreateObject("RDSServer.DataFactory", _
"http://localhost")
sql = "select * from authors"
Set rsSend = dataFactory.query("driver={SQL Server};SERVER=(local);" & _
"database=pubs;uid=sa;pwd=", sql)
mSend.Label = "Testing Recordset"
mSend.Body = rsSend
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 rsReceive = mReceive.Body
Debug.Print rsReceive(0).Value ' print column 1
Debug.Print rsReceive(1).Value ' print column 2
Debug.Print rsReceive(2).Value ' print column 3
rsReceive.MoveNext
Debug.Print rsReceive(0).Value ' print column 1
Debug.Print rsReceive(1).Value ' print column 2
Debug.Print rsReceive(2).Value ' 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/ado/rds
Additional query words:
Keywords : kbDatabase kbRDS150 kbRDS200 kbGrpVBDB kbGrpMDAC kbDSupport MQProg MQVB kbRDS210SP2
Version : WINDOWS:1.5,2.0,2.1 SP2; winnt:1.0
Platform : WINDOWS winnt
Issue type : kbhowto