Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. datareader

datareader

Scheduled Pinned Locked Moved Database
help
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sood_is_in
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • S sood_is_in

      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

      C Offline
      C Offline
      cbhkenshin
      wrote on last edited by
      #2

      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

      S 1 Reply Last reply
      0
      • C cbhkenshin

        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

        S Offline
        S Offline
        sood_is_in
        wrote on last edited by
        #3

        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

        C 1 Reply Last reply
        0
        • S sood_is_in

          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

          C Offline
          C Offline
          cbhkenshin
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups