Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
There will also be times when you need to clear a database table, deleting all the records. For example, suppose at the end of each month you import event log records into a database and then run a series of statistical analyses on that data. At the end of the next month, you might want to clear the table; that way, the next set of records imported into the database will not commingle with any previous records.
Although you can clear a database by finding and deleting each record individually, a better and faster approach is to use an SQL Delete query to delete all the records in a single operation.
Listing 17.20 contains a script that deletes all the records in a database table. To carry out this task, the script must perform the following steps:
These constants will be used to configure the CursorLocation, CursorType, and LockType for the connection.
The Connection object makes it possible for you to issue queries and other database commands.
The Recordset object stores the data returned from your query.
Be sure to append a semicolon (;) to the DSN name.
The Open method requires four parameters:
Listing 17.20 Deleting All Records in a Database Table
|
|
Send us your feedback | « Previous | Next » |