1. Adox Overview Microsoft? ActiveX? Data Objects Extensions for Data Definition Language and Security (adoX) is an extension to the ADO object and programming model. Adox includes objects for model creation and modifying, as well as security. Since it is based on object implementation mode operation, users can write code that can effectively run various data sources, and has nothing to do with the differences in their original syntax.
ADOX is the expansion library of the core ADO object. Other objects that are revealed can be used to create, modify, and delete mode objects, such as tables and procedures. It also includes security objects that can be used to maintain users and groups, and grant and revoke the permissions of objects.
To use Adox by development tool, you need to establish a reference to the Adox Type Library. The description of the Adox library is "Microsoft ADO EXT. For DDL and Security.". The Adox library is named "Msadox.dll", the program ID (Progid) is "Adox". For more information about establishing a library reference, see the documentation for the development tool. 2, Adox Object Catalog contains a collection of description data source mode directories. Column represents the column of the table, index, or keyword. Group indicates a group account that has access to access within the secure database. Index represents the index in the database table. Key represents the primary keywords, external keywords, or unique keywords in the database table. Procedure indicates the process of storage. Table represents a database table, including columns, indexes, and keywords. User represents a user account with access permissions in a secure database. View represents the filter set of records or virtual tables. 3. Adox Method Append (Columns) Adds the new Column object to the columns collection. Append (groups) Add new Group objects to the Groups collection. Append (indexes) adds a new INDEX object to the Indexes collection. Append (keys) adds a new Key object to the KEYS collection. Append (Procedures) Adds the new Procedure object to the Procedures collection. Append (Tables) Add a new Table object to the Tables collection. Append (users) add new User objects to the UserS collection. Append (views) adds a new View object to the Views collection. ChangePassword changes the password of the user account. CREATE Create a new directory. Delete deletes objects in the collection. GetObjectowner returns the owner of the object in the directory. GetPermissions gets permissions for the objects or users. Item returns a specified member of the collection by name or serial number. Refresh updates the objects in the collection to reflect the objects available and specified for the provider. SetObjectowner Specifies the owner of the object in the directory. SetPermissions Sets the permissions of the objects or users. 4, Adox Properties ActiveConnection Indicates the ADO Connection objects you belong to the directory. Attributes describes column characteristics. Clustered indicates whether the index is spathed. Command specifies the ADO Command object that can be used to create or execute. COUNT indicates the number of objects in the collection. Datecreated Indicates the date of creating an object. DATEMODIFIED indicates the date of the last change object. DefinedSIZE indicates the maximum size of the column. DELETERULE indicates the operation that will be performed when the primary key is deleted. IndexNulls Indicates whether there is an index item in the record in the index field. Name indicates the name of the object. NumericScale Indicates the range of values in columns. ParentCatalog Specifies the parent directory of the table or column to access the properties of a particular provider. Precision Indicates the highest accuracy of the data value in the column. PRIMARYKEY indicates whether the index is the primary keyword representing the table. RelatedColumn Indicates the names of the relevant columns in the related table (only key columns only). RelatedTable Indicates the name of the related table. Sortorder Indicates the ordering order of the column (independent columns only). Type indicates the data type of the column. TYPE (keyword) indicates the data type of the keyword. Type indicates the type of table.
UNIQUE indicates whether the index key must be unique. Updaterule indicates the operation that the primary key is updated. 5. Example 1. Creating a DB Act, as follows: How to create a new Jet database via the CREATE method.
SUB CREATEDATABASE ()
Dim cat as new adox.catalog cat.create "" provider = microsoft.jet.Oledb.4.0; data source = c: /new.mdb ""
End Sub II, Create Table Example SUB CreateTable ()
DIM TBL AS New Table Dim Cat As New Adox.catalog
'open Directory. ' open Directory. Cat.activeConnection = _ "" "provider = microsoft.jet.oledb.4.0;" & _ "" Data Source = C: / Program Files / Microsoft Office / "& _" "Office / Samples / Northwind.mdb;" "
TBL.NAME = "" MYTABLE "" TBL.COLUMNS.APPpend "Column1" ", Adinteger TBL.COLUMNS.APpend" Column2 ", Adinteger TBL.COLUMNS.APpend" Column3 ", Advarwchar, 50 Cat.Tables .Append tbl
End Sub I. Creating an indexing model, for example, the following code demonstrates how to create a new index. Index is established for two columns of tables.
SUB CREATEINDEX ()
DIM TBL AS New Table Dim IDX As New Adox.index Dim Cat As New Adox.catalog
' open Directory. ' open Directory. Cat.activeConnection = _ "" "provider = microsoft.jet.oledb.4.0;" & _ "" Data Source = C: / Program Files / Microsoft Office / "& _" "Office / Samples / Northwind.mdb;" "
'Defining the table and append it to the directory TBL.NAME = "" MyTable "" TBL.COLUMNS.APpend "Column1" ", Adinteger TBL.COLUMNS.APPEND" Column2 "", Adinteger TBL.COLUMNS.APPpend "Column3 "", Advarwchar, 50 Cat.Tables.Append TBL
'Define Multi-column index idx.name = "" Multicolidx "" idx.column.Append "" column1 "" idx.columns.Append "" column2 ""
'Add an index to TBL.Indexes.Append IDX
End Sub III, Creating a Keyword Example If the following code demonstrates how to create a new external keyword. Assume that two tables (Customers and Orders) have existing. SUB CREATEKEY ()
DIM KYFOREIGN As New Adox.Key Dim Cat As New Adox.catalog
Cat.activeConnection = "" provider = microsoft.jet.Oledb.4.0; "& _" "Data Source = C: / Program Files / Microsoft Office /" & _ "" Office / Samples / Northwind.mdb; ""
kyForeign.Name = "" CustOrder "" kyForeign.Type = adKeyForeign kyForeign.RelatedTable = "" Customers "" kyForeign.Columns.Append "" CustomerId "" kyForeign.Columns ( "" CustomerId ""). RelatedColumn = "" CustomerId " "KYFOREIGN.UPDaterule = adricascade cat.tables (" ORDERS "). Keys.Append KyForeIgnend Sub