views:

32

answers:

1

Drag access database into designer xsd, toolkit:datagrid get datacontext from resources correctly show the table content through this binding. Press button in the button column, can show each row correctly. delete row and add row also work in datagrid

however, when i press button column to add a new row or delete a row, there is no change in the underlying database, how to commit the changes from datagrid to database in WPF if not using ADO.net ?

The following code is what i try do not work

private void datagrid2_delete(object sender, RoutedEventArgs e)
        {

            Button showButton = (Button)sender;

            //person p = (person)showButton.DataContext;

            DataRowView ds = (DataRowView)showButton.DataContext;

            //DataSet1.customertableRow p = (DataSet1.customertableRow)ds;
            //ds.BeginEdit();
            //ds.Delete();
            //ds.EndEdit();

            /*
            DataSourceProvider provider = (DataSourceProvider)this.FindResource("Family");
            WpfApplication1.DataSet1.customertableDataTable table =
            (WpfApplication1.DataSet1.customertableDataTable)provider.Data;
            table.AddcustomertableRow("hello3", 5, System.DateTime.Today);
            table.AcceptChanges();
}
A: 

Thanks.

Datacontext do not have savechanges options to choose i google that Linq dbml do not support Access and only support MS SQL server that means datacontext.XXXXX can not be used with Access database

At last, i use ADO .Net , OleCommand. It 's the only choice