Populate & Add/Edit/Delete Records from WPF DataGrid
OleDbConnection Con_Admin = new OleDbConnection(); BindingSource bs = new BindingSource(); OleDbDataAdapter da; DataTable dt; public void Show_GridView() { Con_Admin.Open(); dataGridView1.DataSource = null; da = new OleDbDataAdapter(MyQry, Con_Admin); OleDbCommandBuilder MyCommandBuilder = null; MyCommandBuilder = new OleDbCommandBuilder(da); dt = new DataTable(); da.Fill(dt); bs.DataSource = dt; dataGridView1.DataSource = bs; Con_Admin.Close(); } public void SaveChanges() { try { da.Update(dt); } catch (Exception exceptionObj) { MessageBox.Show(exceptionObj.Message.ToString()); } Show_GridView(); }
DataContext
DataTable
BindingSource
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)