/// <summary>
        /// Obtiene un adaptador, según el servidor indicado
        /// </summary>
        /// <param name="server">Servidor a utilizar</param>
        /// <returns></returns>
        public static DbDataAdapter GetDataAdapter(ServerEnumType server)
        {
            switch (server)
            {
            case ServerEnumType.SqlServer:
                return(new SqlDataAdapter());

            case ServerEnumType.MySQL:
                return(new MySqlDataAdapter());

            case ServerEnumType.Oracle:
                return(new OracleDataAdapter());

            default:
                return(null);
            }
        }
        /// <summary>
        /// Inicializa una nueva instancia de la clase DbCommandBuilder con el objeto SqlDataAdapter asociado.
        /// </summary>
        /// <param name="server">Servidor a utilizar</param>
        /// <param name="adapter">Adapater a quien se le rellenan los comandos</param>
        public static DbCommandBuilder GetCommandBuilder(ServerEnumType server, DbDataAdapter adapter)
        {
            switch (server)
            {
            case ServerEnumType.SqlServer:
                return(new SqlCommandBuilder(adapter as SqlDataAdapter));

            case ServerEnumType.MySQL:
                return(new MySqlCommandBuilder(adapter as MySqlDataAdapter));

            case ServerEnumType.Oracle:
                return(new OracleCommandBuilder(adapter as OracleDataAdapter));

            default:
                return(null);
            }
        }
        /// <summary>
        /// Obtiene un objeto comando, según el servidor indicado
        /// </summary>
        /// <param name="server">Servidor a utilizar</param>
        /// <returns>Comando implementado</returns>
        public static DbCommand GetCommand(ServerEnumType server)
        {
            switch (server)
            {
            case ServerEnumType.SqlServer:
                return(new SqlCommand());

            case ServerEnumType.MySQL:
                return(new MySqlCommand());

            case ServerEnumType.Oracle:
                return(new OracleCommand());

            default:
                return(null);
            }
        }
        /// <summary>
        /// Recupera información de parámetro del procedimiento almacenado especificado en SqlCommand
        /// y rellena la colección de Parameters del objeto SqlCommand especificado.
        /// </summary>
        /// <param name="server">Servidor a utilizar</param>
        /// <param name="command">Commando a rellenar con parametros</param>
        public static void DeriveParameter(ServerEnumType server, DbCommand command)
        {
            switch (server)
            {
            case ServerEnumType.SqlServer:
                SqlCommandBuilder.DeriveParameters(command as SqlCommand);
                command.Parameters.RemoveAt("@RETURN_VALUE");
                break;

            case ServerEnumType.MySQL:
                MySqlCommandBuilder.DeriveParameters(command as MySqlCommand);
                break;

            case ServerEnumType.Oracle:
                OracleCommandBuilder.DeriveParameters(command as OracleCommand);
                break;
            }
        }
        /// <summary>
        /// Obtiene una conexion, según el servidor indicado
        /// </summary>
        /// <param name="server">Servidor a utilizar</param>
        /// <returns>Conexion implementada</returns>
        public static DbConnection GetConnection(ServerEnumType server)
        {
            DbConnection connection = null;

            switch (server)
            {
            case ServerEnumType.SqlServer:
                connection = new SqlConnection();
                break;

            case ServerEnumType.MySQL:
                connection = new MySqlConnection();
                break;

            case ServerEnumType.Oracle:
                connection = new OracleConnection();
                break;

            default:
                return(null);
            }
            return(connection);
        }
        /// <summary>
        /// Obtiene un parametro, según el servidor indicado
        /// </summary>
        /// <param name="server">Servidor a utilizar</param>
        /// <returns>Parametro implementado</returns>
        public static DbParameter GetParameter(ServerEnumType server)
        {
            DbParameter parameter = null;

            switch (server)
            {
            case ServerEnumType.SqlServer:
                parameter = new SqlParameter();
                break;

            case ServerEnumType.MySQL:
                parameter = new MySqlParameter();
                break;

            case ServerEnumType.Oracle:
                parameter = new OracleParameter();
                break;

            default:
                return(null);
            }
            return(parameter);
        }
예제 #7
0
 /// <summary>
 /// Constructor por defecto
 /// </summary>
 /// <param name="server">Tipo de servidor a utilizar</param>
 /// <param name="connectionString">Cadena de conexión</param>
 /// <param name="cleanBeforeFill">Indica si los DataSet o DataTable se limpian antes de llenarlos</param>
 public UniversalConnectorImpl(ServerEnumType server, string connectionString, bool cleanBeforeFill)
 {
     this.Server           = server;
     this.ConnectionString = connectionString;
     this.CleanBeforeFill  = cleanBeforeFill;
 }
 /// <summary>
 /// Constructor por defecto
 /// </summary>
 /// <param name="server">Tipo de servidor a utilizar</param>
 /// <param name="connectionString">Cadena de conexión</param>
 public UniversalConnectorDAL(ServerEnumType server, string connectionString)
 {
     this.Server           = server;
     this.ConnectionString = connectionString;
 }