Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ADO.NET: 'IDataReader' to 'OracleDataReader' casting error

523187Apr 15 2008 — edited Apr 21 2008
Hello everyone. Am using ADO.NET to connect to an Oracle Lite 10g Release 3 database from a C# .net compact framework based application running a WM 5.0 PPC Emulator.
Am selecting a value from a the database based on a user specified parameter but i get an error on compilation. Here is the code.

OracleConnection conn = new OracleConnection ("DSN=SALESORDER; uid = system; pwd=john" );
try
{
conn.Open();
OracleCommand cmd = (OracleCommand)conn.CreateCommand();
cmd.CommandText = "SELECT company_name FROM customers WHERE company_name =' " + textBox1.Text + " ' ";
OracleDataReader res = (OracleDataReader)cmd.ExecuteReader();

while (res.Read())
{
textBox1.Text = res.GetString(0);
}


res.Close();

}
catch (OracleException ex)
{
MessageBox.Show(ex.Message);
}


finally
{
conn.Close();
}

On compilation, i get this error:
Error 1 Cannot implicitly convert type 'System.Data.IDataReader' to 'Oracle.DataAccess.Lite.OracleDataReader'. An explicit conversion exists (are you missing a cast?)

What could i be missin or how could i redo the code to achieve same results. Kindly assist.
Ken
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 19 2008
Added on Apr 15 2008
2 comments
2,734 views