Tutorial: Using the Simple Code Sample

The Simple project uses the .NET Data Provider to obtain a result set from the database server.

Prerequisites

You must have Visual Studio and the .NET Framework installed on your computer.

You must have the SELECT ANY TABLE system privilege.

Task

The Simple project is included with the SAP Sybase IQ samples. It demonstrates a simple listbox that is filled with the names from the Employees table.

  1. Start Visual Studio.
  2. Click File » Open » Project.
  3. Browse to %ALLUSERSPROFILE%\SybaseIQ\samples\SQLAnywhere\ADO.NET\SimpleWin32 and open the Simple.sln project.
  4. When you use the SAP Sybase IQ .NET Data Provider in a project, you must add a reference to the Data Provider. This has already been done in the Simple code sample. To view the reference to the Data Provider (iAnywhere.Data.SQLAnywhere), open the References folder in the Solution Explorer window.
  5. 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, right-click Form1.cs and click View Code.

      In the using directives in the top section, you should see the following line:

      using iAnywhere.Data.SQLAnywhere;

      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.

  6. Click Debug » Start Without Debugging or press Ctrl+F5 to run the Simple sample.
  7. In the SQL Anywhere Sample window, click Connect.

    The application connects to the SAP Sybase IQ sample database and puts the surname of each employee in the window, as follows:


    
       Screen shot showing simple window containing a list of employee names and a Connect button.
  8. Close the SQL Anywhere Sample window to shut down the application and disconnect from the sample database. This also shuts down the database server.

You have built and executed a simple .NET application that uses the SAP Sybase IQ .NET Data Provider to obtain a result set from an SAP Sybase IQ database server.