How to Test a Connection

After you create the appropriate connection string and store it in a file, you can programmatically test the validity of your connection with a call to Microsoft.HostIntegration.DataAccessLibrary.DataAccessControl.TestConnection%2A.

Test a connection

  1. Create or retrieve the connection string on which you run the sample query.

    For more information about creating and retrieving connection strings, see Creating a Connection String and How to Retrieve Data.

  2. Test the connection with a call to Microsoft.HostIntegration.DataAccessLibrary.DataAccessControl.TestConnection%2A.

    If successful, Microsoft.HostIntegration.DataAccessLibrary.DataAccessControl.TestConnection%2A returns the class and version number of the server. Otherwise, the method returns null. Note that you may be required to enter the user name and password. In this case, the Password dialog box appears.

See Also

Performing Administrative Tasks