Chapter 20. Updating Data Sources
In this chapter, you'll build on what you learned about accessing a database via ODBC in the previous chapter, and try your hand at updating the Northwind Traders database through the same mechanism.
By the end of this chapter, you will have learned about:
How to update a database using recordset objects
How data is transferred from a recordset to the database in an update operation
How to update an existing row in a table
How to add a new row to a table
When you are just writing code to view information from a database, the only issue is whether you are authorized to access the data. As long as the database has the right kind of access protection, the data in the database is safe. As soon as you start writing code to update a database, it's quite another kettle of fish. Because you are altering the contents of the database, such modifications could destroy the integrity of the database and make nonsense of the contents of a table, or even make it unusable. You always need to take great care to test your code properly with a test database before letting it loose on the real thing.
A database update typically involves modifying one or more fields in a row in an existing table, modifying an order quantity for instance, or adding a new row—a new order perhaps in the context of the Northwind database. You'll be developing examples of both of these, but first, consider the implications.
Most of the complications that can ...