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

/// <summary>
        /// Execute SQL Command,Return single Result.
        /// </summary>
        /// <param>SQL Command collection which will be Executed</param>
        /// <param>SQL Parameters Collection</param>
        /// <returns>return single Result</returns>
        public object ExecScalar(string strSql, SqlParameter[] sqlParameters)
        {
            debug("Now Execute DataBaseAccess's Method:ExecScalar(string,SqlParameter[]),Return Type:object ");
            return ExecScalar(SQLHelper.CreateCommand(strSql, sqlParameters, this.conn));
        }

#endregion

#region ExecScalarEx

/// <summary>
        /// Execute SQL command,if result set has note return 1,if result set is null return 0 
        /// </summary>
        /// <param>SQL Command which will be Executed</param>
        /// <returns>Execute SQL command,if result set has note return 1,if result set is null return 0</returns>
        public int ExecScalarEx(SqlCommand sqlcmd)
        {
            debug("Now Execute DataBaseAccess's Method:ExecScalarEx(SqlCommand),Return Type:int ");
            sqlcmd.Connection = this.conn;
            try
            {
                debug("Execute SQL Command:" + sqlcmd.CommandText);
                this.conn.Open();
                SqlDataReader myDr = sqlcmd.ExecuteReader(CommandBehavior.CloseConnection);

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

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