Product Documentation

c-treeDB API for C# - Developers Guide

Previous Topic

Next Topic

Dropping a Table Under Transaction Control

An extra level of data integrity can be achieved when you drop 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. If the transaction is aborted, the dictionary data for the table is automatically restored to the database dictionary.

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

// start a transaction

ADatabase.Begin();

try

{

// drop MyTable from current database

ADatabase.DropTable("MyTable");

// commit the transaction

ADatabase.Commit();

}

catch (CTException err)

{

// abort the transaction

ADatabase.Abort();

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

}

TOCIndex