Catalog object

The Catalog object allows you to work with groups, users, views, tables, and procedures that define the database.

Creating a new Catalog object

Use new keyword to create a new instance of a Catalog object.

{Create a new instance of a Catalog object.}
catalog = new ADOX.Catalog();

When using Distributed COM (DCOM), create a new Catalog object with the COM_CreateObject() function. In the following example, a new Catalog object is created on the computer “SystemServer”.

{Create a new Catalog object.}
catalog = COM_CreateObject("ADOX.Catalog", "SystemServer");

Creating a Catalog object doesn’t create a database. You must also use the Create method to create a new catalog.


Creating a new catalog

Use the Create method to create a new catalog. To create a new catalog, you must specify both the database type and a name for the database in the connection string.

{Create a catalog.}
conString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb";
catalog.Create(conStringr);

In the previous example, the name of the database is db.mdb, and the database is a Microsoft Jet database. For more information about specifying database types, refer to the help file for the Microsoft ADOX Object Library.

Creating a catalog also creates a Connection object from the Microsoft ActiveX Data Objects (ADO) Object Library. When you close the catalog, you should also close the connection. If you don’t, you may get unpredictable results.


Retrieving a connection

Creating a new catalog also creates or opens a Microsoft ADO connection. Use the ActiveConnection property to retrieve a connection from a Catalog object.

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

Be sure to close all connections to a database. If you don’t, you may get unpredictable results.



Documentation Feedback