Updating records in the database with asp net cheap things to do and dating
In one of our tutorial, we discussed how Persistence is handled in Entity Framework.
Two scenarios are possible when we update and entity.
If we did not change its state to Modify and invoked the Save Changes method, then the Context will insert the new department in the database.
This will result in duplicate Departments in our database.
Now we need to tell the context that the Entity is Updated.
updating is usually done with a primary key and in your case the customer-id is what you will need for updates.For example, if you call Delete on a row on the Data Set, then when Update is called on the Data Adapter, the Delete Command of the Data Adapter will be called using the particular row in the Data Set.Note: Keep in mind that this Update is different than a SQL UPDATE statement.To change an existing row's data, you can directly assign a row's value. Delete() In this example, I'll show you how to add edit, and remove, data from the Northwind database.To save data to the data source, you need to call the Data Adapter's Update method. I'll display the result of the Customers table in a Data Grid after adding, updating, and deleting data from the table.