c# - Changes not being saved back to database -
i trying connect northwinddataset, when user clicks button want data saved database. when run code below no errors data not saved. think connecting dataset correctly , not sure why isn't saving back.
northwinddatasettableadapters.customerstableadapter north = new northwinddatasettableadapters.customerstableadapter(); northwinddataset.customersdatatable northtable = north.getdata(); northwinddataset northwinddataset1 = new northwinddataset(); northwinddataset.customersrow newcustomersrow = northwinddataset1.customers.newcustomersrow(); newcustomersrow.customerid = "5"; newcustomersrow.companyname = "alfreds futterkiste"; northwinddataset1.customers.rows.add(newcustomersrow); northwinddataset1.customers.acceptchanges();
you need commit changes not acceptchanges method use update method on table adapter.
in case this:
north.update(northwinddataset1.customers); northwinddataset1.customers.acceptchanges(); accept changes not commit data database. update does.
Comments
Post a Comment