Globally Inerit Class in an App

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?
 
C

Curt_C [MVP]

"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.
 
K

Kevin Spencer

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.
 

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

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top