Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is ADOX?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "what is ADOX". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is ADOX".

I. Overview of ADOX

Microsoft? ActiveX? Data Objects Extensions for Data Definition Language and Security (ADOX) is an extension of the ADO object and programming model. ADOX includes objects for schema creation and modification, as well as security. Because it implements pattern operations based on objects, users can write code that runs effectively against a variety of data sources, regardless of the differences in their original syntax.

ADOX is an extension library of core ADO objects. It exposes other objects that can be used to create, modify, and delete schema objects, such as tables and procedures. It also includes security objects that can be used to maintain users and groups, as well as to grant and revoke permissions on objects.

To use ADOX through development tools, 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 file is named "Msadox.dll" and the program ID (ProgID) is "ADOX". For more information about creating library references, see the documentation for the development tool.

2. ADOX object

The Catalog contains a collection that describes the data source schema catalog.

Column represents a column of a table, index, or keyword.

Group represents a group account that has access to a secure database.

Index represents an index in a database table.

Key represents a primary, external, or unique keyword in a database table.

Procedure represents a stored procedure.

Table represents a database table, including columns, indexes, and keywords.

User represents a user account that has access rights in a secure database.

View represents the filtered set of records or virtual tables.

3. ADOX method

Append (Columns) adds a new Column object to the Columns collection.

Append (Groups) adds a new Group object 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 a new Procedure object to the Procedures collection.

Append (Tables) adds a new Table object to the Tables collection.

Append (Users) adds a new User object to the Users collection.

Append (Views) adds a new View object to the Views collection.

ChangePassword changes the password of the user account.

Create creates a new directory.

Delete deletes objects in the collection.

GetObjectOwner returns the owner of the object in the directory.

GetPermissions gets the permissions of a group or user on the object.

Item returns the specified member of the collection by name or ordinal.

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 a group or user on an object.

IV. ADOX attribute

ActiveConnection indicates the ADO Connection object to which the directory belongs.

Attributes describes the column properties.

Clustered indicates whether the index is clustered.

Command specifies the ADO Command object that can be used to create or execute the procedure.

Count indicates the number of objects in the collection.

DateCreated indicates the date the object was created.

DateModified indicates the date the object was last changed.

DefinedSize indicates the specified maximum size of the column.

DeleteRule indicates the action to be performed when the primary keyword is deleted.

IndexNulls indicates whether a record with a Null value in the index field has an index entry.

Name indicates the name of the object.

NumericScale indicates the range of values in the column.

The ParentCatalog specifies the parent directory of the table or column to access the properties of a particular provider.

Precision indicates the highest precision of the data values in the column.

PrimaryKey indicates whether the index represents the primary key of the table.

RelatedColumn indicates the name of the related column in the related table (key column only).

RelatedTable indicates the name of the related table.

SortOrder indicates the sort order of the columns (indexed columns only).

Type (column) indicates the data type of the column.

Type indicates the data type of the keyword.

Type (table) indicates the type of table.

Unique indicates whether the index keyword must be unique.

UpdateRule indicates the action to be performed when the primary keyword is updated.

5. Examples

5.1 create a database example

The following code shows how to create a new Jet database using 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

5.2 create a table example

Sub CreateTable ()

Dim tbl As New Table

Dim cat As New ADOX.Catalog

'Open the directory.

'Open the 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.Append "Column1", adInteger

Tbl.Columns.Append "Column2", adInteger

Tbl.Columns.Append "Column3", adVarWChar, 50

Cat.Tables.Append tbl

End Sub

5.3 create an index example

The following code shows how to create a new index. The index is built on two columns of the table.

Sub CreateIndex ()

Dim tbl As New Table

Dim idx As New ADOX.Index

Dim cat As New ADOX.Catalog

'Open the directory.

'Open the directory.

Cat.ActiveConnection = _

"Provider=Microsoft.Jet.OLEDB.4.0;" & _

"Data Source=c:\ Program Files\ Microsoft Office\" & _

"Office\ Samples\ Northwind.mdb;"

'define the table and append it to the directory

Tbl.Name = "MyTable"

Tbl.Columns.Append "Column1", adInteger

Tbl.Columns.Append "Column2", adInteger

Tbl.Columns.Append "Column3", adVarWChar, 50

Cat.Tables.Append tbl

'define a multi-column index

Idx.Name = "multicolidx"

Idx.Columns.Append "Column1"

Idx.Columns.Append "Column2"

'append the index to the table

Tbl.Indexes.Append idx

End Sub

5.4 create a keyword example

The following code shows how to create a new external keyword. Assume that two tables (Customers and orders) already exist.

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 kyForeign

End Sub

Thank you for your reading, the above is the content of "what is ADOX", after the study of this article, I believe you have a deeper understanding of what is ADOX, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report