萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> mysql教程 >> asp.net c# java調用mysql存儲過程方法(1/2)

asp.net c# java調用mysql存儲過程方法(1/2)

asp.net c# java調用mysql存儲過程方法 本文章主要介紹三種asp.net c# java調用mysql存儲過程方法,一一舉例說明了關於如何創建如調用mysql存儲過程的方法哦。

asp教程.net c# java調用mysql教程存儲過程方法
本文章主要介紹三種asp.net教程 c# java調用mysql存儲過程方法,一一舉例說明了關於如何創建如調用mysql存儲過程的方法哦。

簡單存儲過程

 
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()  //"刪除"的存儲過程
     {
        string str_orgid = client_str;  //獲得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"; //存儲過程名
            //mycomm.parameters.add("m_orgid", str_orgid);
             mycomm.executenonquery();
         }
        catch
         {
             mycomm.connection.close();
             mycomm.dispose();
         }
        finally
         {
             mycomm.connection.close();
             mycomm.dispose();
         }
     }

首頁 1 2 末頁

copyright © 萬盛學電腦網 all rights reserved