I am new to Oracle and trying to get data from a Oracle DB. Following is my code. No error is showing in the console. But in the code will not enter inside the while loop. As I am new to this somebody please help me to solve this issue ?
public void Login()
{
using (OracleConnection connection = new OracleConnection())
{
connection.ConnectionString = ConnectionString;
try
{
LogManager.Info("inside login");
connection.Open();
OracleCommand cmd = connection.CreateCommand();
cmd.Connection = connection;
string sql = "select ID from APRV_EMPLOYEE where USERNAME = :username ";
LogManager.Info("sql" + sql);
cmd.CommandType = CommandType.Text;
cmd.CommandText = sql;
cmd.BindByName = true;
cmd.Parameters.Add(":username", OracleDbType.NVarchar2).Value = "admin";
IDataReader reader = cmd.ExecuteReader();
LogManager.Info("Inside DatabaseManager::hasrows");
while (reader.Read())
{
LogManager.Info("Inside DatabaseManager::read" + reader.GetString(1));
LogManager.Info("Inside DatabaseManager::read2" + reader.GetString(reader.GetOrdinal("ID")));
}
reader.Dispose();
cmd.Dispose();
}
catch (Exception ex)
{
LogManager.Error("Inside DatabaseManager::Login " + ex.Message);
}
}
}
Please help me Thanks in advance