【问题标题】:monitoring mysql database in c#在c#中监控mysql数据库
【发布时间】: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";
        }
    }

【问题讨论】:

标签: c# php mysql


【解决方案1】:

不,这种从服务器出站的推送通知对于普通 MySQL 是不可能的。如果您正在寻找 DBMS 中列值的变化,您需要像您一直在做的那样轮询它。

您可以创建一个用户定义的函数并从触发器中调用它。但出于多种原因,这是一种危险的方法。

这是对这个问题的一个体面的讨论。 http://karwin.blogspot.com/2006/10/catch-22-of-active-database.html

【讨论】:

    猜你喜欢
    • 2011-03-10
    • 1970-01-01
    • 2022-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多