zoukankan      html  css  js  c++  java
  • 一直在做一个关于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);  

  • 相关阅读:
    redis-原理-对象-列表对象(八)
    分布式事物-Saga
    分布式事物-本地消息表
    分布式事物-TCC
    分布式事物-XA协议
    Spring Boot-多环境配置(十)
    maven-maven-resources-plugin插件使用
    maven-assembly-plugin插件使用
    20201207 徐艺铭 《信息安全导论》第三周学习总结
    20201207 徐艺铭 第二周学习总结
  • 原文地址:https://www.cnblogs.com/LanWorld/p/2540224.html
Copyright © 2011-2022 走看看