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

SAP Sybase SQL Anywhere 16.0 » SQL Anywhere Server - Programming » .NET application programming » SQL Anywhere .NET Data Provider

 

Using the .NET Data Provider in a Visual Studio project

Use the SQL Anywhere .NET Data Provider to develop .NET applications with Visual Studio by including both a reference to the SQL Anywhere .NET Data Provider, and a line in your source code referencing the SQL Anywhere .NET Data Provider classes.

Prerequisites

There are no prerequisites for this task.

 Task
  1. Start Visual Studio and open your project.

  2. In the Solution Explorer window, right-click References and click Add Reference.

    The reference indicates which provider to include and locates the code for the SQL Anywhere .NET Data Provider.

  3. Click the .NET tab, and scroll through the list to locate any of the following:

    • iAnywhere.Data.SQLAnywhere for .NET 2
    • iAnywhere.Data.SQLAnywhere for .NET 3.5
    • iAnywhere.Data.SQLAnywhere for .NET 4
    Note

    There is separate version of the provider for Windows Mobile platforms. For the Windows Mobile SQL Anywhere .NET Data Provider, click the Browse tab and locate the Windows Mobile version of the provider. The default location is %SQLANY16%\CE\Assembly\V2.

  4. Click the desired provider and then click OK.

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

  5. Specify a directive to your source code to assist with the use of the SQL Anywhere .NET Data Provider namespace and the defined types.

    Add the following line to your project:

    • If you are using C#, add the following line to the list of using directives at the beginning of your source code:

      using iAnywhere.Data.SQLAnywhere;
    • If you are using Visual Basic, add the following line at the beginning of source code:

      Imports iAnywhere.Data.SQLAnywhere

Results

The SQL Anywhere .NET Data Provider is set up for use with your .NET application.

Example

The following C# example shows how to create a connection object when a using directive has been specified:

SAConnection conn = new SAConnection();

The following C# example shows how to create a connection object when a using directive has not been specified:

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

The following Visual Basic example shows how to create a connection object when an Imports directive has been specified:

Dim conn As New SAConnection()

The following Visual Basic example shows how to create a connection object when an Imports directive has not been specified:

Dim conn As New iAnywhere.Data.SQLAnywhere.SAConnection()

 See also