Why sql Data Reader object not created

Answers were Sorted based on User's Feedback



Why sql Data Reader object not created..

Answer / manish t

the command in the above code uses cmd.executereader ()
which means an datareader object is returned as a result of
the execution .....which essentially means one datar reader
object getting assigned to another datareader object

dr = cmd.executereader

so it is simply assigning of objects and does not require
new keyword as the datareader inside the execute reader has
already allocated space and it is just assigning it to a
different object ...this is true with executedataset as
well ...remember the rule is that corret type should be
returned. it is same in case of any objects ..try creating
an object A with new keyword and another object B of same
type without new key word ...and then assign the A to B and
you will find that By ref all properties are avialable to b

Is This Answer Correct ?    7 Yes 0 No

Why sql Data Reader object not created..

Answer / alex dorfman

The type 'System.Data.SqlClient.SqlDataReader' has no
constructors defined

Is This Answer Correct ?    11 Yes 5 No

Why sql Data Reader object not created..

Answer / boopathiraj

we can't create an object for data reader because the
datareader is used to retrive the data's from the database
and it uses only some small amount of databases unlike
dataset.We can just create the variable for the datareader
is possible.And then THE CONSTRUCTORS WAS NOT DEFINED BY
SYSTEM.DATA.SQLCLIENT.SQLDATAREADER.(i.e)when you typed
(System.data.sqlclient)upto this is possible if you use
(System.data.sqlclient)(.sqldatareader)--->Not possible and
it is applicable when you use microsoft visual studio.net

Is This Answer Correct ?    8 Yes 4 No

Why sql Data Reader object not created..

Answer / tahir

The DataReader object is the ADO.NET counterpart of the read-only, forward-only default ADO cursor. The DataSet is a container that can be programmatically filled with static snapshot of data. In this sense, it can be seen as a repository of disconnected recordsets. There's no Recordset component in the ADO.NET object model, but the DataTable object is the .NET double of a disconnected recordset.

Is This Answer Correct ?    2 Yes 1 No

Why sql Data Reader object not created..

Answer / kalirajan

SqlConnection con = new SqlConnection("");
con.Open();
SqlCommand cmd = new SqlCommand("", con);

SqlDataReader dr;

dr = cmd.ExecuteReader();
while (dr.Read())
{
TextBox1.Text = dr[0].ToString();


}

dr.Close();


Try this code...

Is This Answer Correct ?    8 Yes 8 No

Why sql Data Reader object not created..

Answer / tahir

The DataReader object is the ADO.NET counterpart of the read-only, forward-only default ADO cursor. The DataSet is a container that can be programmatically filled with static snapshot of data. In this sense, it can be seen as a repository of disconnected recordsets. There's no Recordset component in the ADO.NET object model, but the DataTable object is the .NET double of a disconnected recordset.

Is This Answer Correct ?    2 Yes 2 No

Why sql Data Reader object not created..

Answer / shakeer

We don't require to create object of DataReader class.

Because , For Example

if any string value is there like "Hello"
we will capture that value into String Class varible.

String s = "Hello";

In the same way when we call ExecuteReader() method, the
return type is DataReader


METHOD RETURN TYPE
ExecuteReader() ----> Datareader

DataReader: Which is having the capacity of holding the data
in the form of Rows and Columns

when we need to capture the value of string type, we
created the variable of the String class & captured it.
Similarly in the case of Datareader, we will create variable
of Datareader and capture the return type of ExecuteReader()
method.


So, DataReader dr = cmd.ExecuteReader();

Is This Answer Correct ?    0 Yes 0 No

Why sql Data Reader object not created..

Answer / manish

after some investigation i have found that because the
sqldatareader has no constructor defined in it an object
cannot be created.

Is This Answer Correct ?    2 Yes 4 No

Why sql Data Reader object not created..

Answer / deep

because it ia an abstract class

Is This Answer Correct ?    7 Yes 13 No

Post New Answer

More ADO.NET Interview Questions

How can we add relation between tables in a dataset?

0 Answers  


FetCh Records No 5 to 10 From Dataset

4 Answers  


How do we invoke queries from the application

2 Answers  


what is meant by connection pooling and event pumbling in ado.net

3 Answers   TCS,


What is the difference between SqlCommand and SqlCommandBuilder?

0 Answers  






how to keep track of index in listbox items.

2 Answers  


How do u implement locking concept for dataset?

2 Answers   ABC,


Why sql Data Reader object not created

9 Answers   Matrix,


What is the current version of entity framework?

0 Answers  


Which method in OLEDBAdapter is used to populate dataset with records?

0 Answers  


What is the default Timeout for SqlCommand.CommandTimeout property?

0 Answers  


Which object of ado contains datarow datacolumn collection?

0 Answers  


Categories