ASA Programming Guide
Using the Adaptive Server Anywhere .NET Data Provider Sample Applications
This tutorial is based on the Table Viewer project that is included with the Adaptive Server Anywhere .NET data provider.
The complete application can be found in your SQL Anywhere installation directory at Samples\ASA\ado.net\TableViewer\TableViewer.csproj.
The Table Viewer project is more complex than the Simple project. It illustrates the following features:
connecting to a database
working with the AsaDataAdapter object
more advanced error handling and result checking
For more information about how the sample works, see Understanding the Table Viewer sample project.
To run the Table Viewer code sample in Visual Studio .NET
Start Visual Studio .NET.
Choose File
Browse to SamplesASA\ado.net\TableViewer in your SQL Anywhere installation directory and open the TableViewer.csproj project.
If you want to 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 Table Viewer 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 Table Viewer code sample. To view the using
directive:
Open the source code for the project.
In the Solution Explorer window, select TableViewer.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 an Imports
line to your source code.
For more information, see Referencing the data provider classes in your source code.
Choose Debug
The Table Viewer dialog appears.
In the Table Viewer dialog, click Connect.
The application connects to the Adaptive Server Anywhere sample database.
In the Table Viewer dialog, click Execute.
The application retrieves the data from the employee table in the sample database and puts the query results in the Results DataList, as follows:
If you attempt to execute the query without first connecting to a database, a message appears instructing you to connect to a database.
You can also execute other SQL statements from this application: enter a SQL statement in the SQL Statement pane and then click Execute.
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 Table Viewer sample project