Adding a Data Source

ODBC and SQL Server

ODBC and SQL Server

Adding a Data Source

ODBC applications typically connect to a database through an ODBC data source. Each ODBC data source on a client computer has a unique data source name, or DSN. An ODBC data source for the Microsoft® SQL Server™ ODBC driver includes all the information required to connect to a server running an instance of SQL Server, plus options, such as a default database or the type of security to use.

There are three types of ODBC data sources:

  • User data source

    User data sources are specific to the Microsoft Windows NT® 4.0, Microsoft Windows® 2000, Microsoft Windows 95, or Microsoft Windows 98 account in effect when they are created. They are not visible to any other login account. They are not always visible to applications running as a service on a Windows NT 4.0 computer.

  • System data source

    System data sources are visible to all login accounts on a client. They are always visible to applications running as a service on a Windows NT 4.0 computer.

  • File data source

    File data sources were added with ODBC version 3.0. File data sources are not stored in the system registry. They are stored in a file on the client.

There are several ways to add a data source:

  • ODBC Administrator

    The ODBC Administrator is installed in Control Panel. The ODBC Administrator has tabs for user, system, and file data sources. Click the proper tab, click Add, and then select the SQL Server ODBC driver. The ODBC Administrator then starts the SQL Server DSN Configuration Wizard.

  • SQLConfigDataSource

    User or system data sources can be created by an ODBC application that calls the SQLConfigDataSource function with the fRequest parameter set to either ODBC_ADD_DSN or ODBC_ADD_SYS_DSN.

  • SQLWriteFileDSN

    A file data source can be created by an ODBC application that calls the SQLWriteFileDSN function.

  • SQLDriverConnect

    If an application specifies the SAVEFILE keyword in the connect string of a successful call to SQLDriverConnect, a file data source is created using the information specified in the SQLDriverConnect connect string.

  • SQLCreateDataSource

    An ODBC application can call the function SQLCreateDataSource to display an ODBC dialog box that guides a user through creating a data source.

Data sources that reference the SQL Server ODBC driver contain driver-specific information and options. When a data source is created with either SQLConfigDataSource or SQLWriteFileDSN, all of the driver-specific information is supplied through keyword-value pairs in a character string passed to the function. When a data source is created using the ODBC Administrator or the SQLCreateDataSource dialog box, the SQL Server DSN Creation wizard is invoked to help you perform the steps to specify the driver-specific information.

The help file for the SQL Server DSN Creation Wizard contains information on the driver-specific options defined through the wizard. These options can also be specified as keywords in SQLConfigDataSource. For more information about the driver-specific options that can be specified with SQLConfigDataSource, see SQLConfigDataSource. The same driver-specific options can also be specified as keywords in the connect string for SQLDriverConnect. For more information about the keywords and their meanings, see SQLDriverConnect.

To start the Microsoft SQL Server DSN Configuration Wizard