Connecting Through a DSN
New Information - SQL Server 2000 SP3.
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"), CCOMVariant("MyUserID"), CCOMVariant("MyPassword"))
Security Note When possible, prompt users to enter their credentials at run time. Avoid storing credentials in a file. If you must persist credentials, you should encrypt them with the Win32 cryptoAPI.