Disabling certain routines/properties when inheriting.....

  • Thread starter Thread starter UJ
  • Start date Start date
U

UJ

I am going to write a class that will inherit from SqlCommand and I want to
disable certain routines in the SqlCommand and add a couple of new routines.
How would I go about doing that? I understand (I think) the inheritance
process but I'm worried more about the disabling of the routines. I want to
disable certain routines and add my own to do some special things.

Thanks for the help.

Jeff.
 
Hi,

Can you give a concrete example?

You can redefine the virtual methods, maybe throwning exception if you dim
it as unnecesary.
 
I want to take SQLCommand and remove ExecuteNonQuery (among others) and
implement my own routine that will do error checking and connection
organization. If I have to I can override the routine but I'd like to remove
it completely so people don't use it by accident.

I'd like to inherit from SQLCommand for all of the things like parameters,
command type, ....

TIA - Jeff
 
Well, your first problem is that SqlCommand is a sealed class which
cannot be inherited from.

It only has about 20 methods/properties and you've already said that
you want to hide some of them. Best just to contain a SqlCommand and
redirect the properites you want to keep:

IDataParameterCollection Parameters
{
get
{
return m_sqlCommand.Parameters
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top