To use the SQL Anywhere .NET Data Provider, you must include two items in your Visual Studio .NET project:
a reference to the SQL Anywhere .NET Data Provider DLL
a line in your source code referencing the SQL Anywhere .NET Data Provider classes
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 tells Visual Studio .NET which DLL to include to find the code for the SQL Anywhere .NET Data Provider.
Start Visual Studio .NET and open your project.
In the Solution Explorer window, right-click References and choose Add Reference from the popup menu.
The Add Reference dialog appears.
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.
For the Windows .NET 2.0 Data Provider, the default location is install-dir\Assembly\v2.
For the Windows CE .NET 2.0 Data Provider, the default location is install-dir\ce\Assembly\v2 for each supported Windows CE hardware platform (for example, ce\Assembly\v2\arm.30).
For the Windows .NET 1.x Data Provider, the default location is install-dir\Assembly\v1.
For the Windows CE .NET 1.x Data Provider, the default location is install-dir\ce\Assembly\v1 for each supported Windows CE hardware platform (for example, ce\Assembly\v1\arm.30).
Select the DLL and then click Open.
For a complete list of installed DLLs, see SQL Anywhere .NET Data Provider required files.
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.
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.
Start Visual Studio .NET and open your project.
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 project:
using iAnywhere.Data.SQLAnywhere;
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.SQLAnywhere
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()