Fill datagridview when inserting data into the SQL Server database

advertisements

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?


You're looking for the SqlDependency, which allows you to listen for changes to the resultset of a SQL query.