using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
namespace Sample2
{
class Program
{
private static string _connStr;
static void Main(string[] args)
{
_connStr = "Data Source=localhost;User Id=sa;Password=xxx;Database=xxx;Pooling=true;Max Pool Size=600;Min Pool Size=0;";
SqlDependency.Start(_connStr);//传入连接字符串,启动基于数据库的监听
UpdateGrid();
Console.Read();
}
private static void UpdateGrid()
{
using (SqlConnection connection = new SqlConnection(_connStr))
{
connection.Open();
//依赖是基于某一张表的,而且查询语句只能是简单查询语句,不能带top或*,同时必须指定所有者,即类似[dbo].[]
using (SqlCommand command = new SqlCommand("select D_Id,D
sqlDependency监控数据库数据变化,自动通知
最新推荐文章于 2024-08-07 02:16:20 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)