ASA Programming Guide
Using the Adaptive Server Anywhere .NET Data Provider Sample Applications
This tutorial is based on the Simple project that is included with the .NET data provider.
The complete application can be found in your SQL Anywhere installation directory at Samples\ASA\ADO.NET\SimpleWin32\Simple.csproj.
The Simple project illustrates the following features:
connecting to a database
executing a query using the AsaCommand object
using the AsaDataReader object
basic error handling
For more information about how the sample works, see Understanding the Simple sample project.
To run the Simple code sample in Visual Studio .NET
Start Visual Studio .NET.
Choose File
Browse to Samples\ASA\ADO.NET\SimpleWin32 in your SQL Anywhere installation directory and open the Simple.csproj project.
When you use the Adaptive Server Anywhere .NET data provider in a project, you must add a reference to the data provider DLL. This has already been done in the Simple code sample. You can view the reference to the data provider DLL in the following location:
In the Solution Explorer window, open the References folder.
You should see iAnywhere.Data.AsaClient in the list.
For instructions about adding a reference to the data provider DLL, see Adding a reference to the data provider DLL in your project.
You must also add a using
directive to your source code to reference the data provider classes. This has already been done in the Simple code sample. To view the using
directive:
Open the source code for the project.
In the Solution Explorer window, select Form1.cs.
Choose View
In the using
directives in the top section, you should see the following line:
using iAnywhere.Data.AsaClient;
This line is required for C# projects. If you are using Visual Basic .NET, you need to add a different line to your source code.
For more information, see Referencing the data provider classes in your source code.
To run the Simple sample, choose Debug
The AsaSample dialog appears.
In the AsaSample dialog, click Connect.
The application connects to the Adaptive Server Anywhere sample database and puts the last name of each employee in the dialog, as follows:
Click the X in the upper right corner of the screen to terminate the application and disconnect from the sample database. This also shuts down the database server.
You have now run the application. The next section describes the application code.
Understanding the Simple sample project