Asp.net c # java call mysql Stored Procedure method this article mainly introduces three methods of asp.net c # java call mysql stored procedure, one by one illustrates how to create a method such as calling mysql stored procedure.
Asp tutorial. net c # java call mysql tutorial Stored Procedure Method
This article mainly introduces three asp.net tutorial c # java methods for calling mysql stored procedures. One by one examples illustrate how to create a mysql stored procedure, for example.
Simple Stored Procedure
Create procedure 'deleteb' (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 Procedure
{
String str_orgid = client_str; // obtain the 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"; // name of the stored procedure
// Mycomm. parameters. add ("m_orgid", str_orgid );
Mycomm.exe cutenonquery ();
}
Catch
{
Mycomm. connection. close ();
Mycomm. dispose ();
}
Finally
{
Mycomm. connection. close ();
Mycomm. dispose ();
}
}
1 2