We help IT Professionals succeed at work.
Get Started

Creating classes in ASP.net that reference SQL server tables and return values

dearness
dearness asked
on
309 Views
Last Modified: 2012-05-12
I am fairly new to ASP.net and want some expert help on best practice code design; I am designing in Visual Studio in express.  I am giving an example of a part of my system design and would appreciate some help on a few design concepts.  I have two power metering database tables set up, tblMETER which holds meter information and tblPOWER which holds 15 minute power meter readings. In my ASP.net program I want to use classes and objects to reference the many power meters.
This is what I think I should do, create a class called PowerMeter, set properties for NUMBER, DESCRIPTION, and DIVIDER. Now when I create an instance of the class for example PM06 (power meter 06), Firstly what is the best way to assign the property values to the new instance, Like this?
DIM PM06 as new PowerMeter
PM06.Number = “06”
PM06.Description = read the database referencing meter number 06
PM06.Divider = read the database referencing meter number 06
Secondly I want to display the total P_KW readings for the meter on a web page.
Do I create another property for the class and assign it the value such as
PM06.Reading = return calculated reading or is there some way of using a method within the class?
Providing some good points on getting a working system using best practices.
 Database Tables
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 2 Answers and 8 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE