Oracle 5.0 Reference Manual page 1929

Table of Contents

Advertisement

This section will not provide in-depth information on creating Stored Procedures. For such information,
please refer to http://dev.mysql.com/doc/mysql/en/stored-routines.html.
A sample application demonstrating how to use stored procedures with Connector/Net can be found in
the
Samples
20.2.5.9.1. Using Stored Routines from Connector/Net
Stored procedures in MySQL can be created using a variety of tools. First, stored procedures can
be created using the
MySQL Workbench. Finally, stored procedures can be created using the
of the
MySqlCommand
Unlike the command-line and GUI clients, you are not required to specify a special delimiter when
creating stored procedures in Connector/Net.
To call a stored procedure using Connector/Net, you create a
stored procedure name as the
CommandType.StoredProcedure.
After the stored procedure is named, you create one
in the stored procedure.
the value,
OUT
be returned. All parameters need the parameter direction defined.
After defining the parameters, you call the stored procedure by using the
MySqlCommand.ExecuteNonQuery()
Once the stored procedure is called, the values of the output parameters can be retrieved by using the
property of the
.Value
The following C# example code demonstrates the use of stored procedures. It assumes the database
'employees' has already been created:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using MySql.Data;
using MySql.Data.MySqlClient;
namespace UsingStoredRoutines
{
class Program
{
static void Main(string[] args)
Connector/Net Programming
Note
When you call a stored procedure, the command object makes an additional
call to determine the parameters of the stored procedure. You must
SELECT
ensure that the user calling the procedure has the
table to enable them to verify the parameters. Failure to do this
mysql.proc
will result in an error when calling the procedure.
directory of your Connector/Net installation.
command-line client. Second, stored procedures can be created using
mysql
object.
.CommandText
parameters are defined with the parameter name and the object containing
IN
parameters are defined with the parameter name and the data type that is expected to
MySqlConnector.Parameters
Note
When a stored procedure is called using MySqlCommand.ExecuteReader,
and the stored procedure has output parameters, the output parameters are
only set after the
MySqlDataReader
MySqlCommand
property. You then set the
MySqlCommand
method.
collection.
returned by
1909
[578]
privilege on the
SELECT
.ExecuteNonQuery
object and pass the
property to
.CommandType
parameter for every parameter
is closed.
ExecuteReader
method

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents