VistaDB 6
VistaDB.DDA Namespace / IVistaDBTableSchema Interface
Members Example


In This Topic
    IVistaDBTableSchema Interface
    In This Topic
    Table schema for usage in creation or altering of an IVistaDBTable.
    Syntax
    'Declaration
     
    
    <System.Reflection.DefaultMemberAttribute("Item")>
    Public Interface IVistaDBTableSchema 
       Inherits IVistaDBDatabaseObject 
    'Usage
     
    
    Dim instance As IVistaDBTableSchema
    [System.Reflection.DefaultMember("Item")]
    public interface IVistaDBTableSchema : IVistaDBDatabaseObject  
    Remarks

    Use the table operators inside the IVistaDBDatabase interface to create instances implementing this interface.

    To alter a schema: Get an instance of this type from the IVistaDBDatabase object, perform the desired modifications, then apply them by calling either IVistaDBDatabase.AlterTable to modify an existing table or IVistaDBDatabase.CreateTable to create a new table.

    Example
    using VistaDB;
    using VistaDB.DDA;
     
    private void CreateTableDdaDemo(string filename)
    {
        // Open a DDA Connection
        using (IVistaDBDDA DDAObj = VistaDBEngine.Connections.OpenDDA())
            // Create a new database (or use OpenDatabase to open an existing one)
        using (IVistaDBDatabase db1 = DDAObj.CreateDatabase(filename, true, null, 2, 0, false))
        {
            // Define a new table schema and add columns and an identity to it
            using (IVistaDBTableSchema table1schema = db1.NewTable("TestTable1"))
            {
                table1schema.AddColumn("ID", VistaDBType.Int);
                table1schema.DefineColumnAttributes("ID", false, false, false, false, null, null);
                table1schema.DefineIdentity("ID", "1", "1");
                table1schema.AddColumn("COLINT", VistaDBType.Int);
                table1schema.DefineColumnAttributes("COLINT", false, false, false, false, null, null);
     
                //Actually create the table in the database from the definition we created
                using (IVistaDBTable table1 = db1.CreateTable(table1schema, false, false))
                {
                    // Add indexes
                    table1.CreateIndex("Primary", "ID", true, true);
                    table1.CreateIndex("idxInt", "COLINT", false, false);
                }
            }
        }
    }
    Imports VistaDB
    Imports VistaDB.DDA
     
    Private Sub CreateTableDdaDemo(filename As String)
        ' Open a DDA Connection
        Using DDAObj As IVistaDBDDA = VistaDBEngine.Connections.OpenDDA()
            ' Create a new database (or use OpenDatabase to open an existing one)
            Using db1 As IVistaDBDatabase = DDAObj.CreateDatabase(filename, True, Nothing, 2, 0, False)
                ' Define a new table schema and add columns and an identity to it
                Using table1schema As IVistaDBTableSchema = db1.NewTable("TestTable1")
                    table1schema.AddColumn("ID", VistaDBType.Int)
                    table1schema.DefineColumnAttributes("ID", False, False, False, False, Nothing, _
                        Nothing)
                    table1schema.DefineIdentity("ID", "1", "1")
                    table1schema.AddColumn("COLINT", VistaDBType.Int)
                    table1schema.DefineColumnAttributes("COLINT", False, False, False, False, Nothing, _
                        Nothing)
     
                    'Actually create the table in the database from the definition we created
                    Using table1 As IVistaDBTable = db1.CreateTable(table1schema, False, False)
                        ' Add indexes
                        table1.CreateIndex("Primary", "ID", True, True)
                        table1.CreateIndex("idxInt", "COLINT", False, False)
                    End Using
                End Using
            End Using
        End Using
    End Sub
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also