I have a queue called log_line_queue in database cja on SQL Server ITSERVER.
I have a C# Win CE application running on a mobile device. I want to send a message from this application to log_line_queue.
This is my code so far:
var myQueue = new System.Messaging.MessageQueue("FormatName:Direct=OS:itserver\\private$\\dbo.cja.log_line_queue");
myQueue.Send("My Message Data.", MessageQueueTransactionType.Automatic);
It results in
System.Messaging.MessageQueueException: Message Queue service is not available.
at System.Messaging.MessageQueue.MQCacheableInfo.get_WriteHandle()
at System.Messaging.MessageQueue.StaleSafeSendMessage(MQPROPS properties, IntPtr transaction)
at System.Messaging.MessageQueue.SendInternal(Object obj, MessageQueueTransactionType transactionType)
at System.Messaging.MessageQueue.Send(Object obj, MessageQueueTransactionType transactionType)
at cjaTest1.MessageQueue.FrmSendToQueue.button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam)
at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
at Microsoft.AGL.Forms.EVL.EnterModalDialog(IntPtr hwnModal)
at System.Windows.Forms.Form.ShowDialog()
at cjaTest1.FrmMainForm.button9_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam)
at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
at Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
at System.Windows.Forms.Application.Run(Form fm)
at cjaTest1.Program.Main()
I’m sure I’m doing many things wrong. Suggestions are welcome.
System.Messaging.MessageQueueis used to interact with MSMQ.A queue called log_line_queue in database cja on SQL Server ITSERVERis either a table or a Service Broker Queue. This is Apples and Oranges, MSMQ has nothing to do with SQL Server. To send messages to a SQL Server queue you must use the SEND T-SQL verb, and you must be connected to a SQL Server instance.