ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/WD_ADONET/html/88bf9b56-5769-4595-98c4-80285d812a5e.htm
这是2005 MSDN的地址

解决方案 »

  1.   

    7楼的兄弟是指什么设置呢?我用示例数据库AdventureWorks一切正常啊。
      

  2.   

    不高啊,MSDN上面有示例的。可是实现的啊。
      

  3.   

    最新追加:我在AdventureWorks数据库建一张表。在Demo上面改的只是查询的表名和字段。同样不能运行,什么原因呢?
      

  4.   

    最新的 sql 补丁打了吗?当你的程序运行的时候, 检查一下 SQL Server 里面有没有 监控的进程
    SELECT * FROM master.sys.sysprocesses
    WHERE program_name LIKE N'SqlQueryNotificationService%'      
      

  5.   

    可以参考一下.net中sql缓存依赖方面的资料,希望对你有帮助。
      

  6.   

    为什么很多兄弟都不相信有这种技术呢?SQL Server2005的查询通知,你们查查资料。
    感谢邹大哥的回答。我先照你的看一看。
      

  7.   

    搞定,代码出奇的简单。但是注意事项比较多。唉痛苦。谢谢各位的支持。 private void GetData()
            {
                SqlDependency depend = new SqlDependency();
                connection = new SqlConnection(connectionString);
                depend.OnChange += new OnChangeEventHandler(depend_OnChange);
                command = new SqlCommand("select orderno,startlocality from dbo.Orders", connection);
                depend.AddCommandDependency(command);
             
                connection.Open();
                dataToWatch = new DataSet();
                SqlDataAdapter ada = new SqlDataAdapter();
                ada.SelectCommand = command;
                ada.Fill(dataToWatch,"test");
                this.dataGridView1.DataSource = dataToWatch;
                this.dataGridView1.DataMember = "test";
            }
            private delegate void ca();
            void depend_OnChange(object sender, SqlNotificationEventArgs e)
            {
                MessageBox.Show("数据已经改变");
                this.Invoke(new ca(GetData));
            }大概就这样啦,结贴。