Call a stored procedure
You can use an IfxCommand object to call a stored procedure. You must set the IfxCommand object CommandType property to StoredProcedure.
The example in this topic shows how to run a stored procedure and read any results returned by the stored procedure using an IfxDataReader object.
For more information about the IfxCommand class, see IfxCommand class. For more information about calling stored procedures, see Call stored procedures.
// Add the IBM Informix namespace
using System.Data;
using Informix.Net.Core;
// Create a connection
IfxConnection conn=new IfxConnection("Host=berry; Service=3500;
Server=testserver; User ID=informix; password=ifxtest;
Database=testdb");
conn.Open();
//Create a command object for the stored procedure
IfxCommand spCmd = new IfxCommand("testproc", conn);
// Set the CommandType property to Storedprocedure
spCmd.CommandType = CommandType.StoredProcedure
IfxDataReader testDataReader;
try
{
testDataReader = spCmd.ExecuteReader();
testDataReader.Close();
}
catch (Exception ex)
{
// Use a messagebox to show any errors
MessageBox.Show (ex.Message);
}
// Close the connection
conn.Close();