【发布时间】:2014-11-25 22:31:58
【问题描述】:
在我的 Visual Studio C# 项目中,我建立了与我的 mySQL 数据库的连接。目前有一个每 0.1 秒执行一次方法的计时器。此方法检查我的 mysql-DB 中的值是否已更改。如果值发生变化,我表单中的标签将像新变量一样被调用。
现在我想在没有计时器的情况下执行此操作,因此应用程序应该识别值是否自行更改。这可能通过使用属性来实现吗?
这是我当前的代码:
private void timer1_Tick(object sender, EventArgs e)
{
Dictionary<string, string> humechDictionary = sqlClientHumech.Select("control");
System.Diagnostics.Debug.WriteLine(humechDictionary);
var countTest = sqlClientHumech.Count("control");
System.Diagnostics.Debug.WriteLine(countTest);
foreach (KeyValuePair<string, string> kvp in humechDictionary)
{
System.Diagnostics.Debug.WriteLine("Key = {0}, Value = {1}",
kvp.Key, kvp.Value);
}
var modusValue = humechDictionary["modus"];
System.Diagnostics.Debug.WriteLine(modusValue);
if (modusValue == "excel")
{
label1.Text = "EXCEL";
}
else if (modusValue == "kinect")
{
label1.Text = "KINECT";
}
else if (modusValue == "manuell")
{
label1.Text = "MANUELL";
}
}
【问题讨论】:
-
这不是数据库有触发器的确切原因吗? (dev.mysql.com/doc/refman/5.5/en/trigger-syntax.html)