I have a method, using Ado.Net to bring DB information (Oracle 11g). There is information in the table (6 records) and when I run it by C#
no record comes. See the code below:
public class ConexaoBanco
{
string conexao = ConfigurationManager.ConnectionStrings["FarmExternaConnect"].ConnectionString;
List<string> listaArquivoFarmExterna = new List<string>();
public bool CriaConexao()
{
OracleConnection conn = new OracleConnection(conexao);
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "select path, arquivo from gh_arquivos_farm_externa";
cmd.CommandType = CommandType.Text;
OracleDataReader dr = cmd.ExecuteReader();
while(dr.Read())
{
listaArquivoFarmExterna.Add(dr.ToString());
//listaArquivoFarmExterna.Add(dr.GetString(1));
}
return listaArquivoFarmExterna.Count > 0? true : false;
}
}
The most interesting thing about this is the following situation. When I get to this line OracleDataReader dr = cmd.ExecuteReader();
and give an F10 (in debug mode), I go forward and when debugging this line there is information (correct), but if I debug the variable dr
in this line while(dr.Read())
, it says:
Enumeration did not produce results
And if I go back to the top row, where there are a few moments ago, I have the same message. I do not know what's going on.