Skip to Main Content

ODP.NET

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!

Empty DataReader when SQL statement contains a join

65350fd4-571b-4896-b003-707aa958290dMay 1 2019 — edited May 1 2019

I am using Oracle.ManagedDataAccess.Core v2.18.6 and I am experiencing an issue when executing a command that includes joins to other tables. I've tried different join syntaxes, etc., and have confirmed joining any table causes the datareader to be empty (.HasRows = false)
I even took the exact same statements and ran them in Oracle SQL Developer and rows come back. What am I missing?

string oradb = "connection string info here";
OracleConnection conn = new OracleConnection(oradb); // C#
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;

//if I select from one table the data reader contains data

cmd.CommandText = "select * from patients where personal_num=1";

//if I select from parent and child table data reader does not contain data
cmd.CommandText = "select a.* from patients a inner join patient_history b on a.personal_num = b.personal_num where personal_num=1"

cmd.CommandType = CommandType.Text;
OracleDataReader dr = cmd.ExecuteReader();
dr.Read();
label1.Text = dr.GetString(0);
conn.Dispose();

This post has been answered by 65350fd4-571b-4896-b003-707aa958290d on May 1 2019
Jump to Answer
Comments
Post Details
Added on May 1 2019
4 comments
975 views