Skip to content

Insertion of records into Data Base using DataReader

Naredla Nithesh

Naredla Nithesh

Asked Aug 10, 2015, 9:56 AM EDT1 answer
Share
LinkedInX
Hi everyone...
According to statement :

A Data Reader is a Forword Only and Read Only Cursor, which is use to fetch data from the database. It cannot be use to Insert any data.

 
Then what is the use of "RecordsEffected" property of "DataReader".

i am very much confused with this....Please explain me in detail...
Thank you.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Naredla Nithesh
    0
    After a lot of search in internet I finally found that the statement is a wrong assumption.Along with the records selection, we can insert,delete,update records.But when we insert/delete/update records the result set does not contain any Data which represents the execution status .So in order to find the effected rows we are using "RecordsEffected" property of DataReader class.
     
     
    But Here the usage of DataReader is inefficient. Instead of that we can use a simple ExecuteNonQuery() method of command Class and assign the return value of this method to an integer gives the effected rows.
     
    Simple but confused one.... :)  
    0