[dba-VB] C# Inheritance question

Arthur Fuller fuller.artful at gmail.com
Sun Apr 22 22:21:47 CDT 2012


I know much  less than you about C# but what you want to do seems like a
violation of the intended design. Anything the base class needs should live
in it, not beneath it, no?

A.

On Sun, Apr 22, 2012 at 10:28 PM, jwcolby <jwcolby at colbyconsulting.com>wrote:

> I have the following code which is in the base class:
>
>        protected bool mLoadFromSQLSrvr(string SQL)
>        {
>            try
>            {
>                cnn = new SqlConnection(clsGlobals.**myConnection);
>                cnn.Open();
>                cmd = new SqlCommand(SQL, cnn);
>                dr = cmd.ExecuteReader();
>                while ((dr.Read()))
>                {
>                    mErrFactory();
>                }
>            }
>            catch (SqlException ex)
>            {
>
> The problem is that mErrFactory is different in the base and derived
> class.  Can this code be told to call the mErrFactory in the derived class?
>  Or do I need to just carve out the while loop and have this method just
> get the data reader something like this:
>
>        protected bool mSQLSrvrReader(string SQL)
>        {
>            try
>            {
>                cnn = new SqlConnection(clsGlobals.**myConnection);
>                cnn.Open();
>                cmd = new SqlCommand(SQL, cnn);
>                dr = cmd.ExecuteReader();
>                return true;
>            }
>        }
>
>        private bool mLoadFromSQLSrvr(string SQL)
>        {
>
>                if mSQLSrvrReader(strsql)
>                {
>                while ((dr.Read()))
>                {
>                    mErrFactory();
>                }
>
>                }
>        }
>
> Then override mLoadFromSqlServer in the derived class?
>
> Since I know how to do the latter I am going there but I am wondering
> whether the base can be told to call an identically named method down in a
> derived class.  It seems unlikely but what do I know?
> --
> John W. Colby
> Colby Consulting
>
> Reality is what refuses to go away
> when you do not believe in it
>
> ______________________________**_________________
> dba-VB mailing list
> dba-VB at databaseadvisors.com
> http://databaseadvisors.com/**mailman/listinfo/dba-vb<http://databaseadvisors.com/mailman/listinfo/dba-vb>
> http://www.databaseadvisors.**com <http://www.databaseadvisors.com>
>
>


-- 
Arthur
Cell: 647.710.1314

Prediction is difficult, especially of the future.
  -- Niels Bohr


More information about the dba-VB mailing list