The Simple project illustrates the following features:
Connecting to a database
Executing a query using the AseCommand object
Using the AseDataReader object
Basic error handling
For more information about how the sample works, see “Understanding the Simple sample project”.
Running the Simple code sample in Visual Studio .NET
Start Visual Studio .NET.
Choose File | Open | Project.
Browse to the sample project:
For C#, browse to <install dir>\Samples\CSharp\Simple and open Simple.csproj.
For Visual Basic .NET, browse to <install dir>\Samples\VB.NET\Simple and open Simple.vbproj.
If you have installed Adaptive Server ADO.NET Data Provider using the installation program, go directly to step 7.
If you have not used the installation program, then you need to correct references to the Adaptive Server ADO.NET Data Provider in the project. To do this, delete the existing reference first:
In the Solution Explorer window, verify that the Simple project is expanded.
Expand the References folder.
Right-click Sybase.AseClient.Data.dll and select Remove.
Add a reference to Adaptive Server ADO.NET Data Provider Assembly.
For instructions, see “Adding a reference to the Data Provider assembly”.
To run the Simple sample, choose Debug | Start Without Debugging, or press Ctrl+F5.
The AseSample dialog box appears.
In the AseSample dialog box, provide connection information for an Adaptive Server with the sample pubs2 database and then click Connect.
The application connects to the sample pubs2 database and puts the last name of each author in the dialog box.
Click X in the upper right corner of the window to terminate the application and disconnect from the pubs2 database.
You have now run the application. The next section describes the application code.
Running the Simple sample project without Visual Studio
From a DOS prompt, go to the appropriate sample directory under <install dir>\Samples.
Add the directory with .NET Framework 1.1 binaries to your system path.
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.
Compile the sample program using the supplied build script called build.bat.
To run the program, enter:
simple.exe
The AseSample dialog box appears.
In the AseSample dialog box, provide connection information for an Adaptive Server with the sample pubs2 database and then click Connect.
The application connects to the sample pubs2 database and puts the last name of each author in the dialog box.
Click the X in the upper right corner of the window to terminate the application and disconnect from the pubs2 database.