Globally Inerit Class in an App

  • Thread starter Thread starter Brad
  • Start date Start date
B

Brad

I have a database class that I have created that handles connecting and
disconnecting and error reporting and all of that so I don't have to do
it in my actual pages. I have a base page that all of my pages inherit
that declares the database class object so on any child page I can say:

MyBase.oDatabase.GetRecord("Select blah from blah where blah")

to get a record.

Is this the best way to do this?
 
"best" is subjective.
Is it a perfectly viable way, yes, especially if your pages are all using
it. If they aren't then it's unecessary overhead.
We use two "base" pages, one with the db, and other, items that are only
used on our maintenance screens and one that's got a few less things in it
for other pages to inherit from. Both of these two pages inherit from one
"master" though so there is littel repetative work.

Just a thought.
 
It would be better if your database class used static methods. That way you
don't have to bother instantiating a class that may or may not be used in
every page. Generally speaking, most database operations are not related to
one another, which makes using static methods a good practice with regards
to database operations.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Back
Top