Connecting to a Jet Repository Database

Meta Data Services Programming

Meta Data Services Programming

Connecting to a Jet Repository Database

If you choose to use a Microsoft® Jet database, you can create it programmatically using the IRepository Create method. If you do not specify a complete path, the repository engine uses the default path. For more information, see Default Repository Databases.

You can create a new database using the syntax provided in the following example. Notice that the first statement creates a repository session.

Use the following code to connect to a Jet database in Microsoft Visual C++®:

CoCreateInstance(CLSID_Repository, NULL, CLSCTX_INPROC_SERVER, IID_IREPOSITORY, (LPVOID *) &m_pIRepos)
m_pIRepos->Create(CCOMVariant(DBQ="MyDB.mdb"), CCOMVariant(""), CCOMVariant(""), 0, &m_pIRootObj)

Use the following code to connect to a Jet database in Microsoft Visual Basic®:

DIM m_pIRepos as New Repository
m_pIRepos.Create(DBQ="MyDB.mdb")

To connect to a Jet repository database, use the DBQ keyword to specify the path to the database file. The DBQ keyword must be the first keyword in the connection string, if it is present. If the DBQ keyword is not present, the connection string is assumed to contain only a database path specification. In this case, the repository will add the DBQ keyword to the front of the ODBC connection string before passing it on to the database server. If the Jet database file specified by the DBQ keyword does not exist, the repository engine will create it.

CoCreateInstance(CLSID_Repository, NULL, CLSCTX_INPROC_SERVER, IID_IREPOSITORY, (LPVOID *) &m_pIRepos)))
m_pIRepos->Open(CCOMVariant(DBQ="MyDB.mdb"), CCOMVariant(""), CCOMVariant(""), 0, &m_pIRootObj))

See Also

Connecting to a SQL Server Repository Database

Default Repository Databases