コード例 #1
0
ファイル: Tutorial3.cs プロジェクト: WooZoo86/ctree
        //
        // Delete_Records()
        //
        // This function deletes all the records in the table
        //

        static void Delete_Records(CTRecord record)
        {
            bool found;

            Console.WriteLine("\tDelete records...");

            try
            {
                // enable session-wide lock flag
                MySession.Lock(LOCK_MODE.WRITE_BLOCK_LOCK);

                // read first record
                found = record.First();

                while (found) // while records are found
                {
                    // delete record
                    record.Delete();
                    // read next record
                    found = record.Next();
                }

                // reset session-wide locks
                MySession.Unlock();
            }
            catch (CTException E)
            {
                Handle_Exception(E);
            }
        }
コード例 #2
0
        //
        // Delete_Records()
        //
        // This function deletes all the records in the table
        //

        static void Delete_Records()
        {
            bool found;

            Console.WriteLine("\tDelete records...");

            try
            {
                // read first record
                found = MyRecord.First();

                while (found)                  // while records are found
                {
                    // delete record
                    MyRecord.Delete();
                    // read next record
                    found = MyRecord.Next();
                }
            }
            catch (CTException E)
            {
                Handle_Exception(E);
            }
        }
コード例 #3
0
        //
        // Delete_Records()
        //
        // This function deletes all the records in the table
        //

        static void Delete_Records(CTRecord record)
        {
            bool found;

            Console.WriteLine("\tDelete records...");

            try
            {
                // write lock required for transaction updates
                record.Lock(LOCK_MODE.WRITE_LOCK);

                // start a transaction
                record.Begin();

                // read first record
                found = record.First();

                while (found) // while records are found
                {
                    // delete record
                    record.Delete();
                    // read next record
                    found = record.Next();
                }

                // commit transaction
                record.Commit();

                // free locks
                record.Unlock();
            }
            catch (CTException E)
            {
                Handle_Exception(E);
            }
        }