Connecting Through a DSN

Meta Data Services Programming

Meta Data Services Programming

Connecting Through a DSN

You can use the DSN keyword to specify a data source name (DSN) to connect to an existing Microsoft® Jet or Microsoft SQL Server™ repository database. The DSN keyword specifies a data source name that has been configured using the ODBC Data Source Administrator.

If you are connecting to a SQL Server database, you must explicitly specify the user ID and password in the connection string, even if the values are part of the ODBC registration.

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

CoCreateInstance(CLSID_Repository, NULL, CLSCTX_INPROC_SERVER, IID_IREPOSITORY, (LPVOID *) &m_pIRepos)))
m_pIRepos->Open(CCOMVariant(DSN="MyDataSourceName";UID="MyUserID";PWD="MyPassword"))

See Also

Connecting to a Jet Repository Database

Connecting to a SQL Server Repository Database

Default Repository Databases