Export (0) Print
Expand All

How to add a data source (ODBC)

SQL Server 2000

  New Information - SQL Server 2000 SP3.

You can add a data source by using ODBC Administrator, programmatically (by using SQLConfigDataSource), or by creating a file.

To add a data source by using ODBC Administrator

  1. On the Start menu, point to Settings, and then click Control Panel.

  2. Double-click ODBC.

  3. Click the User DSN, System DSN, or File DSN tab, and then click Add.

  4. Click SQL Server, and then click Finish.

  5. Complete the Steps in the Create a New Data Source to SQL Server Wizard.

To add a data source programmatically

  • Call SQLConfigDataSource with the fOption set to either ODBC_ADD_DSN or ODBC_ADD_SYS_DSN.

To add a file data source

  • Call SQLDriverConnect with a SAVEFILE=file_name parameter in the connect string. If the connect is successful, the ODBC driver creates a file data source with the connection parameters in the location pointed to by the SAVEFILE parameter.
Examples
A. Create a data source using SQLConfigDataSource

The complete sample code is in this file: CreateDataSourceUsingSQLConfigDataSource.cpp. You can download a file containing this sample from the Microsoft® SQL Server™ Downloads page at this Microsoft Web site.

This sample was developed for ODBC version 3.0 or later. It was developed with Microsoft Visual C++® version 6.0, and may expose properties of the Microsoft Foundation Classes.

B. Create a file data source

Use the SAVEFILE keyword in SQLDriverConnect to create a file data source, and then use SQLDriverConnect to connect with the file data source. This example has been simplified by removing error handling.

The complete sample code is in this file: CreateFileDataSourceAndConnect.cpp. You can download a file containing this sample from the SQL Server Downloads page at this Microsoft Web site.

This sample was developed for ODBC version 3.0 or later. It was developed with Microsoft Visual C++ version 6.0, and may expose properties of the Microsoft Foundation Classes.

See Also

Adding or Deleting an ODBC Data Source

Show:
© 2014 Microsoft