public class QRYExecuter: SqlDataReader
{
}

class is defined as above
while building this, i get exception below:
The type 'System.Data.SqlClient.SqlDataReader' has no constructors defined

pls, can u solve it?

Recommended Answers

All 5 Replies

IMHO you can not derive from SqlDataReader.
The ExecuteReader method of the SqlCommand class will return a SqlDataReader.

instead of SqlDataReader i put SqlCommand but i'm already getting an error:
'DBClass.QRYExecuter': cannot derive from sealed type 'System.Data.SqlClient.SqlCommand'

what's the problem

IMHO you can not derive from SqlDataReader.
The ExecuteReader method of the SqlCommand class will return a SqlDataReader.

instead of SqlDataReader i put SqlCommand but i'm already getting an error:
'DBClass.QRYExecuter': cannot derive from sealed type 'System.Data.SqlClient.SqlCommand'


what's the problem

You cannot derive from a sealed class.
If you absolutely want to have your own QRYExecuter class, you cannot build a "is a" relationship, but you can make a "has a" relationship. Make a field of type SqlCommand in your QRYExecuter class and access it through properties.

You cannot derive from a sealed class.
If you absolutely want to have your own QRYExecuter class, you cannot build a "is a" relationship, but you can make a "has a" relationship. Make a field of type SqlCommand in your QRYExecuter class and access it through properties.

thanx so much, i did this class as u offered. by using sqlcommand properties in a QRYExecuter class

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.