Deleting Data from Tables
One of the last steps in the BuildApplication method is to delete data from the selected tables in the target database. For our user interface, we chose a checked list box in the form because Access doesn't have this control and we think it's cool. The checked list box control has a collection of checked items that we simply need to enumerate.
Add the following code to implement the DeleteTableData method. Again, this might throw a NullReferenceException if the target database does not exist.
private void DeleteTableData() { string sql = null; try { foreach (string tableName in deleteDataListbox.CheckedItems) { // create the SQL statement and execute sql = string.Format("DELETE * FROM [{0}]", tableName); targetDatabase.Execute(sql, Type.Missing); } } catch (NullReferenceException) { // set the error text errorText = "Delete table data failed. " + "Target database does not exist."; } }
In this tutorial:
- Deployment
- Creating an Automated Build
- Design the Form
- Retrieving Information from the Source Database
- Building the Application
- Creating the Target Database
- Set Build Properties on the Target Database
- Setting Build Properties on the Source Database
- Deleting Data from Tables
- Calculating the Version Number
- Handling Application Dependencies
- Updating References
- Testing Reference Fix-Up
- Late Binding
- Licensing Your Applications
- Number of Records
- Restricting the Number of Times an Application is Launched
- Registering an Application
- Creating a Registration Web Service
- Validate the Registration Using the Web Service
- Miscellaneous Deployment Scenarios
- Create the Client Application
- Testing the Versioning Server
- Re-Linking Tables Automatically
- Programmatically Creating DSNs
- Creating a User DSN
- Ensuring an Application Runs Locally