[C#]分享一个以前的项目使用的DataBaseAccess类(14)

SqlParameter[] clonedParms = new SqlParameter[sqlParameters.Length];
            for (int i = 0, j = sqlParameters.Length; i < j; i++)
            {
                clonedParms[i] = (SqlParameter)((ICloneable)sqlParameters[i]).Clone();
            }

return clonedParms;
        }

//----------------------------------------------------------------------------------------------------------------

/// <summary>
        /// Create new SqlComand
        /// </summary>
        /// <param></param>       
        public static SqlCommand CreateCommand(string strSql)
        {
            SqlCommand sqlcmd = new SqlCommand(strSql);
            return sqlcmd;
        }

/// <summary>
        /// Create new SqlComand,Set DataBase Connection
        /// </summary>
        /// <param></param>
        /// <param></param>
        /// <returns></returns>

public static SqlCommand CreateCommand(string strSql, SqlConnection sqlconn)
        {
            SqlCommand sqlcmd = new SqlCommand(strSql, sqlconn);
            return sqlcmd;
        }


        /// <summary>
        /// Create new SqlComand which has Parameters
        /// </summary>
        /// <param></param>
        /// <param></param>       
        public static SqlCommand CreateCommand(string strSql, SqlParameter[] sqlParameters)
        {
            SqlCommand sqlcmd = new SqlCommand(strSql);
            foreach (SqlParameter param in sqlParameters)
            {
                sqlcmd.Parameters.Add(param);
            }
            return sqlcmd;
        }

/// <summary>
        /// Create new SqlComand which has Parameters,Set DataBase Connection
        /// </summary>
        /// <param></param>
        /// <param></param>
        /// <param></param>       
        public static SqlCommand CreateCommand(string strSql, SqlParameter[] sqlParameters, SqlConnection sqlconn)
        {
            SqlCommand sqlcmd = new SqlCommand(strSql, sqlconn);
            foreach (SqlParameter param in sqlParameters)
            {
                sqlcmd.Parameters.Add(param);
            }
            return sqlcmd;
        }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyjwyj.html