Columns and Tables Append Methods, Name Property Example (VB)

From Microsoft ActiveX Data Objects (ADO)

Columns and Tables Append Methods, Name Property Example (VB)

The following code demonstrates how to create a new table.

Sub CreateTable()

    Dim tbl As New Table
    Dim cat As New ADOX.Catalog

'Open the catalog.
    ' Open the Catalog.
    cat.ActiveConnection = _ 
        "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=c:\Program Files\Microsoft Office\" & _
        "Office\Samples\Northwind.mdb;"

    tbl.Name = "MyTable"
    tbl.Columns.Append "Column1", adInteger
    tbl.Columns.Append "Column2", adInteger
    tbl.Columns.Append "Column3", adVarWChar, 50
    cat.Tables.Append tbl

End Sub