Export (0) Print
Expand All

Connecting Through a DSN

SQL Server 2000

  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.

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.

See Also

Connecting to a Jet Repository Database

Connecting to a SQL Server Repository Database

Default Repository Databases

© 2015 Microsoft