Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - Programming » SQL Anywhere .NET Data Provider

Running the sample projects Next Page

Using the .NET Data Provider in a Visual Studio .NET project


To use the SQL Anywhere .NET Data Provider, you must include two items in your Visual Studio .NET project:

These steps are explained below.

For information about installing and registering the SQL Anywhere .NET Data Provider, see Deploying the SQL Anywhere .NET Data Provider.

Adding a reference to the Data Provider DLL in your project

Adding a reference tells Visual Studio .NET which DLL to include to find the code for the SQL Anywhere .NET Data Provider.

To add a reference to the SQL Anywhere .NET Data Provider in a Visual Studio .NET project
  1. Start Visual Studio .NET and open your project.

  2. In the Solution Explorer window, right-click References and choose Add Reference from the popup menu.

    The Add Reference dialog appears.

  3. On the .NET tab, click Browse to locate iAnywhere.Data.SQLAnywhere.dll. Note that there are separate versions of the DLL for each of .NET 1.x and 2.0 and each of Windows and Windows CE.

  4. Select the DLL and then click Open.

    For a complete list of installed DLLs, see SQL Anywhere .NET Data Provider required files.

  5. You can verify that the DLL is added to your project. Open the Add Reference dialog and then click the .NET tab. iAnywhere.Data.SQLAnywhere.dll appears in the Selected Components list. Click OK to close the dialog.

    The DLL is added to the References folder in the Solution Explorer window of your project.

Using the Data Provider classes in your source code

To facilitate the use of the SQL Anywhere .NET Data Provider namespace and the types defined in this namespace, you should add a directive to your source code.

To facilitate the use of Data Provider namespace in your code
  1. Start Visual Studio .NET and open your project.

  2. Add the following line to your project:

  3. This directive is not required, however, it allows you to use short forms for the SQL Anywhere ADO.NET classes. For example:

    SAConnection conn = new SAConnection()

    Without this directive, you can still use the following:

    iAnywhere.Data.SQLAnywhere.SAConnection  
     conn = new iAnywhere.Data.SQLAnywhere.SAConnection()