/// <summary>
        /// Preenche apenas as tabelas de dados especificadas.
        /// </summary>
        /// <param name="sources">Os nomes das origens. Formato de cada uma: <c>dataTable:tabela_ou_view</c></param>
        public int FillData(params string[] sources)
        {
            try
            {
                int c = 0;
                using (AdpConnection conn = CreateConnection())
                {
                    foreach (string rawInfo in sources)
                    {
                        FillInfo fi = new FillInfo(rawInfo);
                        using (AdpDataAdapter da = new AdpDataAdapter())
                        {
                            if (fi.Source == fi.DataTable && ds.Tables.Contains(fi.DataTable))
                            {
                                DataTable dt = ds.Tables[fi.DataTable];
                                lock (dt)
                                {
                                    string old = dt.TableName;
                                    dt.TableName = GetPhysicalTableName(dt);
                                    new AdpCommandBuilder(da, conn, dt, AdpCommandOperation.Select);
                                    c           += da.Fill(dt);
                                    dt.TableName = old;
                                }
                            }
                            else
                            {
                                da.SelectCommand = new AdpCommand("SELECT * FROM " + fi.Source, conn);
                                if (!ds.Tables.Contains(fi.DataTable))
                                {
                                    Debug.WriteLine(String.Format("WARN: DataTable {0} doesn't exist.", fi.DataTable));
                                }
                                c += da.Fill(ds, fi.DataTable);
                            }
                        }
                    }
                }

                return(c);
            }
            catch (Exception ex)
            {
                throw new ConnectorException("Erro ao realizar o preenchimento dos dados", ex);
            }
        }
 /// <summary>
 /// Preenche um <see cref="DataTable"/> com o resultado da Stored Procedure.
 /// </summary>
 public int Fill(DataTable dt)
 {
     try
     {
         using (AdpDataAdapter da = new AdpDataAdapter(cmd))
             return(da.Fill(dt));
     }
     catch (Exception ex)
     {
         throw ConnectorExceptionFactory.FromDatabaseException(ex)
               .Detail("Erro ao executar stored procedure {0}", cmd.CommandText);
     }
 }
        /// <summary>
        /// Preenche a tabela de dados especificada, com os critérios especificados.
        /// </summary>
        /// <param name="dataTable">O nome da tabela no DataSet que deverá ser preenchida.</param>
        /// <param name="query">A consulta de origem dos dados</param>
        public int FillData(string dataTable, ISqlQuery query)
        {
            string sql = null;

            try
            {
#if DEBUG
                Debug.WriteLine("FillData");
                Debug.IndentLevel++;
                Debug.WriteLine("Data Table: " + dataTable);
                Debug.WriteLine("SQL: " + Regex.Replace(query.ToString().Replace(Environment.NewLine, " "), "\\s+", " "));
                Debug.IndentLevel--;
#endif
                sql = query.ToString();
                DataTable dt = ds.Tables[dataTable];
                if (dt != null)
                {
                    sql = Regex.Replace(sql, "FROM\\s+" + dataTable, "FROM " + GetPhysicalTableName(dt), RegexOptions.IgnoreCase);
                }

                using (AdpConnection conn = CreateConnection())
                    using (AdpDataAdapter da = new AdpDataAdapter())
                    {
                        da.SelectCommand = new AdpCommand(sql, conn);

                        return(da.Fill(ds, dataTable));
                    }
            }
            catch (Exception ex)
            {
                if (sql == null)
                {
                    throw new ConnectorException("Erro ao realizar o preenchimento dos dados", ex);
                }
                else
                {
                    throw ConnectorExceptionFactory.FromDatabaseException(ex, sql);
                }
            }
        }
		/// <summary>
		/// Preenche um <see cref="DataTable"/> com o resultado da Stored Procedure.
		/// </summary>
		public int Fill(DataTable dt)
		{
			try
			{
				using (AdpDataAdapter da = new AdpDataAdapter(cmd))
					return da.Fill(dt);
			}
			catch (Exception ex)
			{
				throw ConnectorExceptionFactory.FromDatabaseException(ex)
					.Detail("Erro ao executar stored procedure {0}", cmd.CommandText);
			}
		}
		/// <summary>
		/// Preenche apenas as tabelas de dados especificadas.
		/// </summary>
		/// <param name="sources">Os nomes das origens. Formato de cada uma: <c>dataTable:tabela_ou_view</c></param>
		public int FillData(params string[] sources) 
		{
			try 
			{
				int c = 0;
				using (AdpConnection conn = CreateConnection()) 
				{
					foreach (string rawInfo in sources) 
					{
						FillInfo fi = new FillInfo(rawInfo);
						using (AdpDataAdapter da = new AdpDataAdapter())
						{
							if (fi.Source == fi.DataTable && ds.Tables.Contains(fi.DataTable)) 
							{
								DataTable dt = ds.Tables[fi.DataTable];
								lock (dt) 
								{
									string old = dt.TableName;
									dt.TableName = GetPhysicalTableName(dt);
									new AdpCommandBuilder(da, conn, dt, AdpCommandOperation.Select);
									c += da.Fill(dt);
									dt.TableName = old;
								}
							}
							else
							{
								da.SelectCommand = new AdpCommand("SELECT * FROM " + fi.Source, conn);
								if (!ds.Tables.Contains(fi.DataTable))
									Debug.WriteLine(String.Format("WARN: DataTable {0} doesn't exist.", fi.DataTable));
								c += da.Fill(ds, fi.DataTable);
							}
						}
					}
				}

				return c;
			}
			catch (Exception ex)
			{
				throw new ConnectorException("Erro ao realizar o preenchimento dos dados", ex);
			}
		}
		/// <summary>
		/// Preenche a tabela de dados especificada, com os critérios especificados.
		/// </summary>
		/// <param name="dataTable">O nome da tabela no DataSet que deverá ser preenchida.</param>
		/// <param name="query">A consulta de origem dos dados</param>
		public int FillData(string dataTable, ISqlQuery query)
		{
			string sql = null;
			try 
			{
#if DEBUG
				Debug.WriteLine("FillData");
				Debug.IndentLevel++;
				Debug.WriteLine("Data Table: " + dataTable);
				Debug.WriteLine("SQL: " + Regex.Replace(query.ToString().Replace(Environment.NewLine, " "), "\\s+", " "));
				Debug.IndentLevel--;
#endif
				sql = query.ToString();
				DataTable dt = ds.Tables[dataTable];
				if (dt != null)
					sql = Regex.Replace(sql, "FROM\\s+" + dataTable, "FROM " + GetPhysicalTableName(dt), RegexOptions.IgnoreCase);
			
				using (AdpConnection conn = CreateConnection()) 
				using (AdpDataAdapter da = new AdpDataAdapter())
				{
					da.SelectCommand = new AdpCommand(sql, conn);

					return da.Fill(ds, dataTable);
				}
			}
			catch (Exception ex)
			{
				if (sql == null)
					throw new ConnectorException("Erro ao realizar o preenchimento dos dados", ex);
				else
					throw ConnectorExceptionFactory.FromDatabaseException(ex, sql);
			}
		}