5.6.2 Example - Executing a Stored Procedure with IN Parameters

Table of Contents Previous Next


5 Using the .NET Connector : 5.6 Using SPL Stored Procedures in your .NET Application : 5.6.2 Example - Executing a Stored Procedure with IN Parameters

The following example demonstrates calling a stored procedure that includes IN parameters. To create the sample procedure, invoke EDB-PSQL and connect to the Advanced Server host database. Enter the following SPL code at the command line:
Calling a stored procedure that contains parameters is very similar to executing a stored procedure without parameters. The major difference is that when calling a parameterized stored procedure you must use the EDBParameter collection of the EDBCommand object. When the EDBParameter is added to the EDBCommand collection, properties such as ParameterName, DbType, Direction, Size, and Value are set.
In the example, the body of the Page_Load method declares and instantiates an EDBConnection object. The sample then creates an EDBCommand object with the properties needed to execute the stored procedure.
The example then uses the Add method of the EDBCommand Parameter collection to add six input parameters.
The Prepare() method prepares the statement before calling the ExecuteNonQuery() method.
The ExecuteNonQuery method of the EDBCommand object executes the stored procedure. After the stored procedure has executed, a test record is inserted into the emp table and the values inserted are displayed on the webpage.

5 Using the .NET Connector : 5.6 Using SPL Stored Procedures in your .NET Application : 5.6.2 Example - Executing a Stored Procedure with IN Parameters

Table of Contents Previous Next