Contents Index Developing Applications with the .NET Data Provider Connecting to a database

ASA Programming Guide
  Developing Applications with the .NET Data Provider

Using the .NET provider in a Visual Studio .NET project


Once you have installed the Adaptive Server Anywhere .NET data provider, you must make two changes to your Visual Studio .NET project to be able to use it:

For information about installing and registering the Adaptive Server Anywhere .NET data provider, see Deploying the Adaptive Server 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 Adaptive Server Anywhere .NET data provider.

To add a reference to the Adaptive Server 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 the References folder and choose Add Reference from the popup menu.

    The Add Reference dialog appears.

  3. On the .NET tab, click Browse to locate iAnywhere.Data.AsaClient.dll. (The default location is \Program Files\Sybase\SQL Anywhere 9\win32). Select the DLL and click Open.

    Note that there is a separate version of the DLL for each of Windows and Windows CE.

    For a complete list of installed DLLs, see Adaptive Server Anywhere .NET data provider required files.

  4. You can verify that the DLL is added to your project. Open the Add Reference dialog and then click the .NET tab. iAnywhere.Data.AsaClient.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.

Referencing the data provider classes in your source code 

In order to use the Adaptive Server Anywhere .NET data provider, you must also add a line to your source code to reference the data provider. You must add a different line for C# than for Visual Basic .NET.

To reference the data provider classes in your code

  1. Start Visual Studio .NET and open your project.

  2. If you are using C#, add the following line to the list of using directives at the beginning of your project:

    using iAnywhere.Data.AsaClient;
  3. If you are using Visual Basic .NET, add the following line at the beginning of your project before the line Public Class Form1:

    Imports iAnywhere.Data.AsaClient

    This line is not strictly required. However, it allows you to use short forms for the Adaptive Server Anywhere classes. Without it, you can still use

    iAnywhere.Data.AsaClient.AsaConnection      
     conn = new iAnywhere.Data.AsaClient.AsaConnection()

    instead of

    AsaConnection   conn = new AsaConnection()

    in your code.


Contents Index Developing Applications with the .NET Data Provider Connecting to a database