ASP tutorial. NET C # java calling MySQL tutorial stored procedure methods
This article mainly introduces three kinds of asp.net tutorial C # java Call MySQL stored procedure method, each example illustrates how to create such as invoking the MySQL stored procedures OH.
Simple stored Procedures
CREATE PROCEDURE ' Deletedb ' (in M_orgid char (12))
Begin
Delete from Hardwareinfo where orgid=m_orgid;
Delete from AddressInfo where orgid=m_orgid;
End
Aspx.net
public void Delete_procedure ()//"delete" stored procedures
{
string str_orgid = Client_str; Get OrgID
String myconn_str = webconfigurationmanager.connectionstrings["mysqlconnectionstring"].connectionstring;
Mysqlconnection myconn = new Mysqlconnection (MYCONN_STR);
Mysqlcommand Mycomm = new Mysqlcommand ("Deletedb", myconn);//(CLIENT_STR);
Mycomm.connection = myconn;
Try
{
Mycomm.connection.open ();
Mycomm.commandtype = CommandType.StoredProcedure;
Mysqlparameter Myparameter;
Myparameter = new Mysqlparameter ("? M_orgid", mysqldbtype.string);
Myparameter.value = Str_orgid;
Myparameter.direction = ParameterDirection.Input;
Mycomm.parameters.add (Myparameter);
Mycomm.commandtext = "Deletedb"; Stored Procedure Name
Mycomm.parameters.add ("M_orgid", Str_orgid);
Mycomm.executenonquery ();
}
Catch
{
Mycomm.connection.close ();
Mycomm.dispose ();
}
Finally
{
Mycomm.connection.close ();
Mycomm.dispose ();
}
}