日期:2014-05-16 浏览次数:20637 次
ALTER DEFINER=`root`@`localhost` PROCEDURE `GetTestProgramByNameAndVersion`(in _displayName varchar(255),in _version char(10)) BEGIN select Id,DisplayName,Version from testpragram where DisplayName=_displayName and Version=_version; END
public MySqlDataReader ExcuteReader(string sql, CommandType type, params MySqlParameter[] parameters) { MySqlConnection conn = null; try { conn = GetOpenedConnection(); MySqlCommand command = new MySqlCommand(sql, conn); command.CommandType = type; if (parameters != null) { command.Parameters.AddRange(parameters); } return command.ExecuteReader(); } catch (System.Exception e) { throw new Exception(e.Message); } }
MySqlParameter param1=new MySqlParameter("?_displayName",MySqlDbType.String,255); param1.Value="MySql存储过程测试"; MySqlParameter param2=new MySqlParameter("?_version",MySqlDbType.String,10); param2.Value="0.02"; MySqlParameter[] parameters = { param1, param2 }; MySqlDataReader reader = ExcuteReader("GetTestProgramByNameAndVersion", CommandType.StoredProcedure, parameters);