database - C# Oracle OracleDataReader.Read() -


i've ran little problem oracle , c#. when i'm running query returns 0 rows, rd.read() = false. it's weird, because there records in database. running exact same query in sql developer returns 2 rows.

i'm running oracle xe 11.2

can maybe explain why dr.read() returns false?

edit: connecting database works 100%.

    public list<chatmessage> receivemessage(string account_id, string account_id2)     {         //initialize list of strings messages         list<chatmessage> list = new list<chatmessage>();          //make connection         oracleconnection con = new oracleconnection(connstring);         con.open();          //make query         string query = "select sender_id, receiver_id, message, msg_date tbl_chat sender_id = '1' , receiver_id = '2' or sender_id = '2' , receiver_id = '1' order msg_date desc";          //add parameters         oraclecommand cmd = new oraclecommand();         //cmd.parameters.add("account_id", account_id);         //cmd.parameters.add("account_id2", account_id2);          cmd.connection = con;         cmd.commandtext = query;          //execute query , initialize reader         oracledatareader dr = cmd.executereader();          //start reading messages , add them list         while(dr.read())         {             string sender_id = dr.getstring(0);             string receiver_id = dr.getstring(1);             string message = dr.getstring(2);             datetime date = dr.getdatetime(3);              chatmessage msg = new chatmessage(message, sender_id, receiver_id, date);             list.add(msg);         }          //close database         con.close();          return list;     } 

that happen if datareader has nothing read, means query executed results in empty set or collection, try running same using sqlplus or sqldeveloper , verify point


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -