一直在做一个关于mysql 调用存储过程的问题,却不会达到想要的效果,不知道哪错了

public static int ExecuteNonQuery(MySqlConnection connection, CommandType cmdType, string cmdText, params MySqlParameter[] commandParameters)
{
MySqlCommand cmd = new MySqlCommand();

PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
// cmd.Connection = connection;
// cmd.CommandText = cmdText;
int val = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
return val;
}
private static void PrepareCommand(MySqlCommand cmd, MySqlConnection conn, MySqlTransaction trans, CommandType cmdType, string cmdText, MySqlParameter[] cmdParms)
{
if (conn.State != ConnectionState.Open)
{
try
{
conn.Open();
}
catch (Exception ex)
{

}
}

if (trans != null)
{
cmd.Transaction = trans;
}

if (cmdParms != null)
{
foreach (MySqlParameter parm in cmdParms)
{
cmd.Parameters.Add(parm);
}
}
cmd.Connection = conn;
cmd.CommandText = cmdText;
cmd.CommandType = cmdType;
}


public static string ConnectionString
{
get
{

string s = ConfigurationManager.ConnectionStrings["MySql"].ConnectionString;
//string row = ConfigurationManager.AppSettings["Encrypt"];
//if (row != null)
//{
// if (!(row == "Base64"))
// {
// if (row == "Vector")
// {
// _connStr = Utility.Encryption.Encryption.Vector_Decrypt(s, key);
// goto Label_0077;
// }
// }
// else
// {
// _connStr = Utility.Encryption.Encryption.Base64_Decrypt(s, true);
// goto Label_0077;
// }
//}
return s;
}
}

 

调用 方法 

MySqlHelper.ExecuteNonQuery(conn, "AddPictrue", null);  

posted @ 2012-06-07 14:04  明天的太阳  阅读(190)  评论(0编辑  收藏  举报