I'm having trouble reading the returned values from a select
, on the line where I do:
OracleDataReader reader = cmd.ExecuteReader();
In read
it brings me the values correctly, but on the next line where I do reader.Read()
says that the enumeration did not produce results.
How do I solve this problem?
Source
OracleConnection cnn = new OracleConnection(DataFunctions.GetDefaultConnectionString()); OracleCommand cmd = cnn.CreateCommand(); OracleDataAdapter adapter = new OracleDataAdapter();
try
{
cnn.Open();
cmd.Connection = cnn;
cmd.CommandText = String.Format("select * from VI_TESTE where cd_codigo = {0}", code);
OracleDataReader reader = cmd.ExecuteReader();
// Ao debugar, aqui tem registros
if (reader.Read())
{
// aqui não tem mais registros
var test1 = reader.GetValue(0);
}
}
finally
{
cnn.Close();
}