2011-09-06 21 views

回答

1
StringBuilder sb = new StringBuilder(); 

using (SqlDataReader rdr = cmd.ExecuteReader()) 
{ 
    while (rdr.Read()) 
    { 
    sb.AppendLine(rdr["name"].ToString() + ' ' + rdr["lname"].ToString()); 
    } 
} 

notifyIcon.BalloonTipText = sb.ToString(); 
notifyIcon.ShowBallonTip(30000); 
+0

謝謝,我不知道如何使用DataReader的,我不能使用的ExecuteScalar因爲我的輸出是名字,LNAME,我想我應該谷歌如何使用DataReader的 – Arash

+0

感謝,現在我想知道如果我有兩個記錄的名稱和lname我應該如何顯示他們?例如在ballontiptext我想顯示:alex a,fred b – Arash

+0

@arash另一個更新。 – LarsTech

2

from The MS notifyicon page,你需要知道如何執行sql命令嗎?

this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); 

     // The Icon property sets the icon that will appear 
     // in the systray for this application. 
     notifyIcon1.Icon = new Icon("appicon.ico"); 

     // The ContextMenu property sets the menu that will 
     // appear when the systray icon is right clicked. 
     notifyIcon1.ContextMenu = this.contextMenu1; 

     // The Text property sets the text that will be displayed, 
     // in a tooltip, when the mouse hovers over the systray icon. 
     notifyIcon1.Text = SqlCommandResultsHere; 
     notifyIcon1.Visible = true; 

     // Handle the DoubleClick event to activate the form. 
     notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick); 
相關問題