Пример #1
0
        /// <summary>
        /// 执行指定数据库连接字符串的数据阅读器
        /// </summary>
        /// <param name="connectionString">一个有效的数据库连接字符串</param>
        /// <param name="cmdType">命令类型 (存储过程,命令文本或其它)</param>
        /// <param name="cmdText">存储过程名或T-SQL语句</param>
        /// <param name="dbParameters">执行命令所需要的数据库参数</param>
        /// <returns>返回包含结果集的IDataReader对象</returns>
        public IDataReader ExecuteReader(string connectionString, CommandType cmdType, string cmdText,
                                         params IDataParameter[] dbParameters)
        {
            var connection = DbConnectionHelper.CreateConnection(_dbType, connectionString);

            return(ExecuteReader(connection, cmdType, cmdText, dbParameters));
        }
Пример #2
0
 /// <summary>
 /// 执行指定类型的数据库命令
 /// </summary>
 /// <param name="connectionString">数据库连接字符串</param>
 /// <param name="cmdType">数据库命令类型(存储过程、文本以及其它)</param>
 /// <param name="cmdText">存储过程名称或者SQL语句</param>
 /// <param name="dbParameters">执行命令所需要的参数数组</param>
 /// <returns>返回命令所影响的行数</returns>
 public int ExecuteNonQuery(string connectionString, CommandType cmdType, string cmdText,
                            params IDataParameter[] dbParameters)
 {
     using (var connection = DbConnectionHelper.CreateConnection(_dbType, connectionString))
     {
         return(ExecuteNonQuery(connection, cmdType, cmdText, dbParameters));
     }
 }