ADO.Net
Why we can not create the object of DataReader class?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Jul 21, 2014, 12:56 AM
The SqlCommand.ExecuteReader() method returns an instance of the SqlDataReader class.data rows would be assigned to the cmd.ExecuteReader and it's previous assignment to an empty SqlReader would be pointless. Furthermore, the cmd.ExecuteReader() works as a factory method creating the SqlDataReader instance. we can't go about using the new keywords as SqlDataReader and also doesn't have a public constructor defined for SqlReader class.
hope this will help you.
Vikram AgrawalPosted Jul 20, 2014, 11:10 AM
when we create the object of SqlDataReader then its shows an compile time error that SqlDataReader class doesnt have any constructor in it.
and when we go to the meta data file of SqlDataReader there is no constructor presents in it.
VulpesPosted Jul 19, 2014, 12:18 PM