查询通知--痛苦整整36小时 ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/WD_ADONET/html/88bf9b56-5769-4595-98c4-80285d812a5e.htm这是2005 MSDN的地址 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 7楼的兄弟是指什么设置呢?我用示例数据库AdventureWorks一切正常啊。 不高啊,MSDN上面有示例的。可是实现的啊。 最新追加:我在AdventureWorks数据库建一张表。在Demo上面改的只是查询的表名和字段。同样不能运行,什么原因呢? 最新的 sql 补丁打了吗?当你的程序运行的时候, 检查一下 SQL Server 里面有没有 监控的进程SELECT * FROM master.sys.sysprocessesWHERE program_name LIKE N'SqlQueryNotificationService%' 可以参考一下.net中sql缓存依赖方面的资料,希望对你有帮助。 为什么很多兄弟都不相信有这种技术呢?SQL Server2005的查询通知,你们查查资料。感谢邹大哥的回答。我先照你的看一看。 搞定,代码出奇的简单。但是注意事项比较多。唉痛苦。谢谢各位的支持。 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)); }大概就这样啦,结贴。 SQL 月份相加问题 谁有仓库管理数据库表设计的案例? 一条SQL语句能搞定吗? 问:SQL2000中分批查询数据的几个问题! 有没有好的SQL SERVER 性能监控、sql语句调优工具 使用触发器同时插入,能否根据某一字段判断是否点火数据库。 =======什么叫做储存过程?==== sql 创建函数并返回 sql联合查询 mssql多表查询的问题! 求教关于Update语句的难题 求救~~如何使两个SQL服务器中表结构相同的数据库中所有表的数据进行对比更新?
SELECT * FROM master.sys.sysprocesses
WHERE program_name LIKE N'SqlQueryNotificationService%'
感谢邹大哥的回答。我先照你的看一看。
{
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));
}大概就这样啦,结贴。