2013-02-01 182 views
0

我在SQL Server ITSERVER上的數據庫cja中有一個名爲log_line_queue的隊列。從C#Win CE發送消息到SQL Server消息隊列CE

我有一個運行在移動設備上的C#Win CE應用程序。我想從這個應用程序發送消息到log_line_queue。

這是我到目前爲止的代碼:

var myQueue = new System.Messaging.MessageQueue("FormatName:Direct=OS:itserver\\private$\\dbo.cja.log_line_queue"); 

myQueue.Send("My Message Data.", MessageQueueTransactionType.Automatic); 

它導致

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() 

我知道我在做很多事情錯了。歡迎提出建議。

回答

1

System.Messaging.MessageQueue用於與MSMQ進行交互。 A queue called log_line_queue in database cja on SQL Server ITSERVER是表或Service Broker隊列。這是Apple和Oranges,MSMQ與SQL Server無關。要將消息發送到SQL Server隊列,必須使用T-SQL動詞SEND,並且您必須連接到SQL Server實例。

+0

謝謝,這解釋了很多。 – cja