Tutorial: Using the Table Viewer code sample

This tutorial is based on the Table Viewer project that is included with Adaptive Server ADO.NET Data Provider. The complete application can be found in your Adaptive Server ADO.NET Data Provider installation directory.

For C#:

 <install dir>\Samples\CSharp\TableViewer\TableViewer.csproj

For Visual Basic .NET:

<install dir>\Samples\VB.NET\TableViewer\TableViewer.vbproj

The Table Viewer project is more complex than the Simple project. It illustrates the following features:

For more information about how the sample works, see “Understanding the Table Viewer sample project”.

StepsRunning the Table Viewer code sample in Visual Studio .NET

  1. Start Visual Studio .NET.

  2. Choose File | Open | Project.

  3. Browse to the Samples directory in your Adaptive Server ADO.NET Data Provider installation directory. Go to the CSharp or VB.NET directory and open the Table viewer project.

  4. If you have installed Adaptive Server ADO.NET Data Provider using the installation program, go directly to step 7.

  5. If you have not used the installation program, then you need to correct references to Adaptive Server ADO.NET Data Provider in the project. To do this, delete the existing reference first:

    1. In the Solution Explorer window, verify that the Simple project is expanded.

    2. Expand the References folder.

    3. Right-click Sybase.AseClient.Data.dll and select Remove.

  6. Add a reference to the Adaptive Server ADO.NET Data Provider Assembly.

    For instructions, see “Adding a reference to the Data Provider assembly”.

  7. To run the TableViewer sample, choose Debug | Start Without Debugging or press Ctrl+F5.

  8. In the Table Viewer dialog box, supply connection information to an Adaptive Server with pubs2 sample database installed. Click Connect.

    The application connects to the Adaptive Server pubs2 sample database.

  9. In the Table Viewer dialog box, click Execute.

    The application retrieves the data from the authors table in the sample database and puts the query results in the Results DataList.

    You can also execute other SQL statements from this application. Enter a SQL statement in the SQL Statement pane and click Execute.

  10. Click the X in the upper right-hand corner of the window to terminate the application and disconnect from the sample database.

StepsRunning the Table viewer sample project without Visual Studio

  1. Open a DOS prompt and go to the appropriate sample directory under <install directory>\Samples.

  2. Add the directory with .NET Framework 1.1 binaries to your system path.

  3. Verify that the dll directory under Adaptive Server ADO.NET Data Provider installation directory is included in the system path and the LIB environment variable.

  4. Compile the sample program using the supplied build script build.bat.

  5. To run the program, enter:

    tableviewer.exe
    
  6. In the Table Viewer dialog box, supply connection information to an Adaptive Server with pubs2 sample database installed.

    Click Connect.

    The application connects to the Adaptive Server pubs2 sample database.

  7. In the Table Viewer dialog box, click Execute.

    The application retrieves the data from the authors table in the sample database and puts the query results in the Results DataList.

    You can also execute other SQL statements from this application: Enter a SQL statement in the SQL Statement pane, and then click Execute.

  8. Click the X in the upper right-hand corner of the window to terminate the application and disconnect from the sample database.

You have now run the application. The next section describes the application code.