Clicking the Build button beside a connection string setting brings up the Connection String Builder dialog, which allows you to visually build and test a connection string.

The first choice to make is the .NET provider to use: System.Data.Odbc for an ODBC data source, System.Data.OleDb for an OLE DB data source, and System.Data.SqlClient for a Microsoft SQL Server data source. Which other settings appear depends on the .NET provider you selected.

For System.Data.Odbc, select DSN if you want to use an ODBC DSN or Connection string if you want to enter the components, such as driver and server, that make up a connection string.

For DSN, the following settings are available:

  • DSN: choose the desired DSN from the drop-down list.

  • User name: enter the user name to use or leave it blank for a trusted connection.

  • Password: enter the password to use or leave it blank for a trusted connection.

For Connection string, the following settings are available:

  • Driver: select the driver to use from the drop-down list.

  • Server: enter the name of the server to connect to. This option isn't available for file-based databases such as Microsoft Access or Pervasive.

  • Database: for file-based databases such as Microsoft Access or Pervasive, enter the folder or path to the database file. For server-based databases such as Microsoft SQL Server or Oracle, enter the database name.

  • User name: enter the user name to use or leave it blank for a trusted connection.

  • Password: enter the password to use or leave it blank for a trusted connection.

  • Other settings: enter any additional settings required by the driver or database.

For System.Data.OleDb, the following settings are available:

  • OLE DB Provider: enter the name of the provider to use.

  • Server: enter the name of the server to connect to. This option isn't available for file-based databases such as Microsoft Access or Pervasive.

  • Database: for file-based databases such as Microsoft Access or Pervasive, enter the folder or path to the database file. For server-based databases such as Microsoft SQL Server or Oracle, enter the database name.

  • User name: enter the user name to use or leave it blank for a trusted connection.

  • Password: enter the password to use or leave it blank for a trusted connection.

  • Other settings: enter any additional settings required by the driver or database.

  • Build: click this button to display the Windows Data Link Properties dialog, which allows you to visually create the connection string by making the appropriate choices in the dialog. Note that it's better to select the correct OLE DB provider for your database engine than to use the generic Microsoft OLE DB Provider for ODBC Drivers, since that provider doesn't have all of the features of a specific provider. For example, the ODBC provider cannot read relationships between tables from databases such as SQL Server or Access.

For System.Data.SqlClient, the following settings are available:

  • Server: enter the name of the server to connect to.

  • Database: enter the database name.

  • User name: enter the user name to use or leave it blank for a trusted connection.

  • Password: enter the password to use or leave it blank for a trusted connection.

You can add additional providers by editing ConnectionStrings.xml; see the Using Other Databases for Meta Data help topic.

Regardless of the .NET provider you selected, the Connection string setting contains the connection string constructed from the settings you entered. You can edit the connection string if you wish. To test that the connection string is valid, click the Test button.

See www.connectionstrings.com for connection strings for different ODBC drivers and OLE DB providers.