I am building a sale application on wpf and I have a datagrid that contains sales data and at each time I execute an insert, delete or update query, I have to perform the display query shown below, is there any way I can bind the datagrid directly to the SQL Server table, so that it's updated automatically when the SQL Server table is changed?
Code behind:
connection.open();
SqlDataAdapter adapter = new SqlDataAdapter("SELECT*FROM Comptoir", connection);
tble.Clear();
adapter.Fill(tble);
ComptoirGrid.ItemsSource = tble.DefaultView;
connection.close();