output parameter example
Posted: Tue 20 Dec 2005 18:32
Are there any examples of using an output parameter with MySQLDirect.NET?
Discussion forums for open issues and questions concerning database tools, data access components and developer tools from Devart
https://forums.devart.com/
Code: Select all
CREATE PROCEDURE testproc(IN param1 INTEGER(11), OUT param2 INTEGER(11))
BEGIN
SET param2=param1*2;
ENDCode: Select all
MySqlConnection myConn = new MySqlConnection("user id=root;database=demobase;host=localhost;password=root");
myConn.Open();
MySqlCommand command = new MySqlCommand("call testproc(10, @param2);select @param2", myConn);
using (IDataReader reader = command.ExecuteReader()) {
if (reader.Read())
Console.WriteLine("@param2 = " + reader[0]);
}
myConn.Close();Code: Select all
CREATE PROCEDURE testproc(INOUT param1 INTEGER(11))
BEGIN
SET param1=param1*2;
ENDCode: Select all
MySqlConnection myConn = new MySqlConnection("user id=root;database=demobase;host=localhost;password=root");
myConn.Open();
MySqlCommand command = new MySqlCommand("set @param1=11;call testproc(@param1);select @param1", myConn);
using (IDataReader reader = command.ExecuteReader()) {
if (reader.Read())
Console.WriteLine("@param1 = " + reader[0]);
}
myConn.Close();