Call a stored procedure: snippet

from the Artful MySQL Tips List


In the mysql client:
DELIMITER $$
CREATE PROCEDURE test( aparam VARCHAR(50) )
BEGIN
SELECT * FROM mytable;
END $$
DELIMITER ;
C# code for dotNet:
mycommand = new MySqlCommand( procName, myconn );
myda = new MySqlDataAdapter( mycommand );
myparam = mycommand.Parameters.Add( new MySqlParameter( "?aparam", MySqlDbType.Int32 ) );
myparam.value = "Anything you need";
mycom.ExecuteNonQuery();
if( myda != null )
  myda.Fill( aDataTable );

Last updated 22 May 2024


Return to the Artful MySQL Tips page