龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 数据库类 > MySQL 技术 >

asp.net c# java调用mysql存储过程方法

时间:2011-03-14 23:24来源:未知 作者:admin 点击:
分享到:
asp教程.net c# java调用mysql教程存储过程方法 本文章主要介绍三种asp.net教程 c# java调用mysql存储过程方法,一一举例说明了关于如何创建如调用mysql存储过程的方法哦。 简单存储过程 cre

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
精彩图集

赞助商链接