简体   繁体   中英

Fill datagridview when Data insert into SQL Server database

I am developing Windows application which contains a datagridView. When data is inserted into SQL Server database then I want to display it in the DataGridView.

Now I am using a timer which pings the database (open DB connection, execute query, if data found then change datasource of DataGridView).

Is there any other method which run when data inserted into table (no need to ping DB)? Can I use Windows services?

在此处输入图片说明

您正在寻找SqlDependency ,它使您可以侦听对SQL查询结果集的更改。

我正在使用此链接 .its使用SqlDependency的聊天应用程序进行数据更改事件

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM