Using the SqlCommandBuilder to Save Changes Back to Your Database

Now that you have seen how easy it is to manipulate data in both a DataView and DataTable you're probably wondering how hard is it to save these changes back to your database. Well, the answer is very easy. In this section I'll demonstrate how to use some of ADO.NET's built-in functionality to easily save data edited within a DataTable back to your database. I'll also be demonstrating how to use the SqlCommandBuilder to automatically generate your UPDATE, DELETE, and INSERT SQL statements. In the next section, “Bringing It All Together,” I'll demonstrate another turnkey method to save your changes back to your database.

Using the SqlCommandBuilder (or one of its counterparts, ...

Get Programming Data-Driven Web Applications with ASP.NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.