SetTableSchema

ODBPPLib.IODBPP.SetTableSchema changes the schema of a table.
void SetTableSchema (
   uint tableId,
   TableSchema schema,
   object fieldMapping
);

Parameters

tableId The table Id defining the table's handle.
schema Pointer to a valid schema or null to rebuild table as is.
fieldMapping An array of int values allowing this method to map field from there old schema to the new - eg. fieldMapping[0] = 2, will move the value in the first field of the old table into the third field of the new table. Sub fields are appended to the end so that <fields><sub fields 1><sub fields 2> and so no.

Image of Field Number Order

Return Values

Remarks

  • If fieldMapping parameter is missing, than SetTableSchema will map the first fixed field to the first fixed field, the second fixed field to the second and so on, plus the first variable field to the first variable field and so on.
  • SetTableSchema is not part of the transaction.
  • When schema equals NULL SetTableSchema attempts a rebuild and/or upgrade for the table file to its current standard and this will also open the table.
Example Use
  • C#
public static uint FIRST_TABLE = 1;
private void button1_Click(object sender, EventArgs e)
   try{
      ODBPPLib.ODBPP odbpp = new ODBPPLib.ODBPP();
      odbpp.OpenDatabase("C:\\My\\Database\\Control\\File.odc");
      odbpp.BeginTransaction(odbpp.SHARED, 60000);
      odbpp.OpenTable(FIRST_TABLE);
      ODBPPLib.TableSchema schema = odbpp.GetTableSchema(FIRST_TABLE);
      if(schema.indexes.Count > 0){
         schema.indexes.Remove(schema.indexes.Count-1);
         odbpp.SetTableSchema(FIRST_TABLE,schema,null);
      }
   }
   catch (Exception e1)
   {
      MessageBox.Show(e1.Message);
   }
}

Also See

GetTableSchema
 

Contact Ekky Software

All around the world Ekky Software is contactable seven days of the week by submitting the following details.

Thank you for your time and interest.
Ekky Software Customer Support Team.

Ekky Software Product Range
Ekky Software Homepage Texas Business Software ObjectDatabase++ TScript Ekky Software Homepage Texas Business Software ObjectDatabase++ TScript