This tutorial is based on the Advanced 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\Advanced\Advanced.csproj
For Visual Basic .NET:
<install dir>\Samples\VB.NET\Advanced\Advanced.vbproj
The Advanced project illustrates the following features:
Connecting to a database
Using the trace event feature to trace ADO.NET calls made to Adaptive Server ADO.NET Data Provider
You can use the trace event feature to log all the ADO.NET calls you make to troubleshooting and gathering more information for Sybase Technical Support.
Using named parameters (“@param”)
Using parameter markers (“?”),
for example: {? = call sp_hello(?, ?,
?)}
Calling stored procedures using input, input/output, output parameters, and return values. There are two ways you can call stored procedures in Adaptive Server:
Using the name of the stored procedure as CommandText and setting AseCommand.CommandType to CommandType.StoredProcedure.
Using call syntax, which is compatible with ODBC and JDBC programs.
Running the Advanced code sample in Visual Studio .NET
Start Visual Studio .NET.
Choose File | Open | Project.
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 Advanced project.
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, 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 the Adaptive Server ADO.NET Data Provider Assembly.
Choose Debug | Start Without Debugging to run the Advanced project.
The Form1 dialog box appears.
In the Form1 dialog box, click Connect.
The application connects to the Adaptive Server sample database.
In the Form1 dialog box, click Execute.
The application executes the stored procedure and gets back an input-output parameter, output parameter, and a return value.
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.
Running the Advanced sample project without Visual Studio
Open a DOS prompt and go to the appropriate sample directory under the <install directory>\Samples directory.
Add the directory with .NET Framework 1.1 binaries to your system path.
Verify that the dll directory under the 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 build.bat.
To run the program, enter:
advanced.exe
The Form1 dialog box appears. Click Connect.
The application connects to the Adaptive Server sample database.
In the Form1 dialog box, click Execute.
The application executes the stored procedure and gets back an input-output parameter, output parameter, and a return value.
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.