Product Documentation

c-treeDB API for C# - Developers Guide

Previous Topic

Next Topic

Deleting a Table Under Transaction Control

An extra level of data integrity can be achieved when you delete a table from a database under transaction control. When the transaction is committed, the changes to the database dictionary data for the table are committed to disk and the table and index files are deleted from disk. If the transaction is aborted, the dictionary data for the table is automatically restored to the database dictionary and the original data and index files are restored to their original state.

The code fragment below shows how to delete an existing table under transaction control. No error checking is included in the sample code:

// start a transaction

try

{

// delete MyTable from current database

string password;

ADatabase.DeleteTable("MyTable", password);

// commit the transaction

ADatabase.Commit();

}

catch (CTException err)

{

// abort the transaction

ADatabase.Abort();

Console.Write("Delete table failed with code {0}\n", err.GetErrorCode());

}

TOCIndex