473,388 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

problem of datareader

as sqldatareader is a class so why we can not create object of that class directly using new keyword.
Jan 4 '07 #1
6 1802

prabhat tiwari wrote:
as sqldatareader is a class so why we can not create object of that class directly using new keyword.
SqlDataReader class hasn't got constructor, so you cannot instantiate
that class.

We user SqlDataReader only when we use commandobject.ExecuteReader()
method.

Jan 4 '07 #2
Hi,
There are classes that are not intended to be created by the user, only
methods from the same library can internally create them and return an
instance. These classes are refered to as noncreatable classes.

There are numerous examples of these kind of classes in the framework.

I was trying to look for a good definition but was unable to find one, so
take the above explanation as a starting point and maybe somebody else will
post a more detailed explanation
--
Ignacio Machin
machin AT laceupsolutions com
<prabhat tiwariwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
as sqldatareader is a class so why we can not create object of that class
directly using new keyword.

Jan 4 '07 #3
first of all thanks for reply i know that sqlcommand's executereader method give the instance of sqldatareader but why we can not make it directly and i know that you can not make a instance of the class
1.it should be abstract
2.it have private constrcutor.
what can be the possibilty try to find out n share with us
Jan 5 '07 #4
Even if you could, what would you do with it?
<prabhat tiwariwrote in message
news:ub**************@TK2MSFTNGP03.phx.gbl...
first of all thanks for reply i know that sqlcommand's executereader
method give the instance of sqldatareader but why we can not make it
directly and i know that you can not make a instance of the class
1.it should be abstract
2.it have private constrcutor.
what can be the possibilty try to find out n share with us


Jan 5 '07 #5
i just want to know how can we create such type of class it will some intersting point about class which we do not know
Jan 5 '07 #6
Hi

<prabhat tiwariwrote in message
news:uY****************@TK2MSFTNGP06.phx.gbl...
>i just want to know how can we create such type of class it will some
intersting point about class which we do not know
The secret is in how you declare the constructor of the type:

1- Declare it private, in this case you will have to provide a static method
that return an instance:

class C{
static public C GetA_C() { return new C();}
private C(){}
}

2- Declare it internal (as in the case of the Reader), in this way another
class define din the same assembly can call it

class C{

internal C(){}
}

class D{
public C GetA_C(){ return new C();}
}

--
Ignacio Machin
machin AT laceupsolutions com
Jan 5 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: sam | last post by:
Hello group, I have a function which is used to initiate sqlDataReader object. I was trying to invoke the close method on the DataReader object but cant really do that as the function returns a...
1
by: VIJAY KUMAR | last post by:
Hi, Problem: Return ArrayList where Values are Added using DataReader. Note: My Data Reader returns M Columns and N Rows I am using DataReader in Data Access layer. I want to return this...
5
by: Scott Shuster | last post by:
Hi, I'm having some strange problems in VS employing a DataReader. Here's a small snippet of the code: .... objDR = objCMD.ExecuteReader() If objDR.Read() Then (true stuff) Else
5
by: DaM | last post by:
Hi guys, I'm having this problem with my ASP.Net application: I was testing the whole site, and it seem to work fine. Fast and stable, but suddenly it stopped working and this error occurred:...
1
by: Brent | last post by:
I'm having a hard time wrapping my head around how to build a multi-dimensional array of n length out of a DataReader loop. Take this pseudo-code: ======================================= public...
11
by: Siv | last post by:
Hi, I seem to be having a problem with a DataAdapter against an Access database. My app deletes 3 records runs a da.update(dt) where dt is a data.Datatable. I then proceed to update a list to...
5
by: Chad | last post by:
I want to create a class which contains a date, integer and string property which all allow a NULL value. I don't want to store the values in an Object datatype. I prefer more strongly typed...
5
by: Varangian | last post by:
Hello there people, I'm having some kind of problem. I have a function that returns a datareader. At some point using the application I get an error "Unspecified error" (ssssoooo helpful) :). I...
3
by: =?Utf-8?B?ZGVuIDIwMDU=?= | last post by:
Hi, Trouble in retaining values of dropdownlist, textboxes, and other controls when dropdownlist selectedindexchanged event is triggered, the controls are inside a user control and this user...
2
by: =?Utf-8?B?TWlrZVo=?= | last post by:
I created a function to use DAAB return a datareader. The connection must keep opening when I consume the datareader. 1. I tested the function, it works. Even I use the datareader after 10...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.