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

What are the important features of ado.net 2.0?

0 Answers  


Explain how to create dynamic gridview?

0 Answers  


What is difference between ado.net and asp net?

0 Answers  


What is the use of sqldatareader class?

0 Answers  


What is ole in vb?

0 Answers  






What is the difference in record set and dataset?

0 Answers  


How to pass values into a datatable?

0 Answers  


What are the steps in connecting to database ?

2 Answers   Microsoft,


What are different types of Commands available with DataAdapter ?

1 Answers   Arigo Infotech,


how to keep track of index in listbox items.

2 Answers  


What is difference between executequery and executeupdate?

0 Answers  


What do you know about ado.net's methods?

0 Answers  


Categories