datareader
-
Can any one plz tell me why we do not use new keyword in oracledataReader that is why this gives error OracleDataReader objectDR=new OracleDataReader(); Thanks In advance
-
Can any one plz tell me why we do not use new keyword in oracledataReader that is why this gives error OracleDataReader objectDR=new OracleDataReader(); Thanks In advance
Hi, if you want to use the datereader then usually you use to get all the results of the query so basically it's read the result of a query from the DB. Below you can find a sample code that will use a query text to put it in the Oracle Command and then Retrive the results with the use of Datareaer Where a DataReader Return the resulted rows one by one each time it Uses .Read() Method wich return a bool with false if all the rows are all ready readed. //code sample to use DataReader class
oracleConnection1.Open(); string query_txt = "Select * from any_table"; OracleDataReader ordr1 = new OracleCommand(query_txt,oracleConnection1).ExecuteReader(); while( ordr1.Read()) { MessageBox.Show(ordr1[0].ToString(); } oracleConnection1.Close();
//where ordr1[0].ToString() 0 is the first column in the select statement -
Hi, if you want to use the datereader then usually you use to get all the results of the query so basically it's read the result of a query from the DB. Below you can find a sample code that will use a query text to put it in the Oracle Command and then Retrive the results with the use of Datareaer Where a DataReader Return the resulted rows one by one each time it Uses .Read() Method wich return a bool with false if all the rows are all ready readed. //code sample to use DataReader class
oracleConnection1.Open(); string query_txt = "Select * from any_table"; OracleDataReader ordr1 = new OracleCommand(query_txt,oracleConnection1).ExecuteReader(); while( ordr1.Read()) { MessageBox.Show(ordr1[0].ToString(); } oracleConnection1.Close();
//where ordr1[0].ToString() 0 is the first column in the select statementThanx for your interest in my query but what i want to know is why have u done OracleDataReader ordr1 = new OracleCommand(query_txt,oracleConnection1).ExecuteReader(); instead why u did not do this OracleDataReader ordr1 = new OracleDataReader(); // that is why we do not use new keyword with darareader Thanxs in Advance
-
Thanx for your interest in my query but what i want to know is why have u done OracleDataReader ordr1 = new OracleCommand(query_txt,oracleConnection1).ExecuteReader(); instead why u did not do this OracleDataReader ordr1 = new OracleDataReader(); // that is why we do not use new keyword with darareader Thanxs in Advance
okay, usually if you use the new command it will give u an Error ("No Constructors Defined") right and cuz it was ment basically for reading the date from a Command (at least this is what i Know!)so if you just want to initilaize it then make it OracleDataReader ordr1 = null; //or with out Intilaizing it OracleDataReader ordr1; thnx.