jwcolby
jwcolby at colbyconsulting.com
Sun Apr 22 21:28:35 CDT 2012
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