有沒有辦法讓每次表更改時ms sql表發送信息? 我希望ToolStripMenuItem的標題在每次有人向表中插入值時進行更改。Cc#當表更改時SQL查詢更新?
我做了一個計時器,每更新x秒,但它會更好,如果它更新只有當sql表已更改。
我的代碼:
//Rexton ordre klar til bestilling
command.CommandText = "SELECT COUNT(*) from bestillinger WHERE firma = @rexton and udlevering BETWEEN @date and @dateadd";
command.Parameters.AddWithValue("@bernafon", "Bernafon");
command.Parameters.AddWithValue("@gn_resound", "GN Resound");
command.Parameters.AddWithValue("@oticon", "Oticon");
command.Parameters.AddWithValue("@phonak", "Phonak");
command.Parameters.AddWithValue("@rexton", "Rexton");
command.Parameters.AddWithValue("@siemens", "Siemens");
command.Parameters.AddWithValue("@widex", "Widex");
con.Open();
command.ExecuteNonQuery();
string result = command.ExecuteScalar().ToString();
con.Close();
if (result != "0")
{
rextonToolStripMenuItem.Text = "rexton " + result;
rextonToolStripMenuItem.ForeColor = System.Drawing.ColorTranslator.FromHtml("#FF1919");
}
http://msdn.microsoft.com/en-us/library/62xk7953(v=vs.110).aspx – 2014-09-23 14:34:29
@TimSchmelter爲什麼不張貼作爲回答您的評論? – JotaBe 2014-09-23 15:20:58