Script example

The following example uses objects from the Microsoft ADOX Object Library to create a table, named “BuyerInfo”, and a primary key for the table.

local ADOX.Catalog catalog;
local ADOX.Table adoxTable;
local ADOX.Key tableKey;
local ADODB.Connection connection;
local string conString;

{Define the ADO connection string.}
conString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\RESM\RESM.MDB";

{Create a new database.}
catalog = new ADOX.Catalog();

{Retrieve the active connection.}
connection = catalog.ActiveConnection;

{Create a table.}
adoxTable = catalog.Tables.Append("BuyerInfo");

{Create the columns in the table.}
adoxTable.Columns.Append("BuyerID", ADOX.adVarWChar);
adoxTable.Columns.Append("FirstName", ADOX.adVarWChar);
adoxTable.Columns.Append("LastName", ADOX.adVarWChar);
adoxTable.Columns.Append("PhoneNumber", ADOX.adVarWChar);

{Create a key for the table.}
tableKey = adoxTable.Keys.Append("ByBuyerID");

{Set the key type.}
tableKey.Type = ADOX.adKeyPrimary;

{Create the column in the key.}

{Close the connection.}

{Clear variables.}
clear tableKey;
clear adoxTable;
clear catalog;
clear connection;


Documentation Feedback