penfold69 Posted May 23, 2005 Posted May 23, 2005 Imagine you have a database with a table in it. Imagine that you wish to represent this table in your code as a class. What is the most efficient (maintenance-wise) way of representing your database table? Currently, I'm trying to decide. I can either go for something like: Public Class MyClass Protected mID as Long Protected mSomeField as String Protected mSomeOtherField as Long .. repeat private member for each database field #Region "Properties" Public Property ID() as Long Get return mID End Get Set (Byval Value as Long) mID = Value End Set End Property (... repeat property for each private member) #End Region Public Sub New() ' perhaps overloaded constructor to handle loading by ID and pre-setting all values End Sub Public Sub Save() 'Various DB code to save back to database End Sub End Class Or, I could go with a Hashtable-type system, whereby the values are stored in a hashtable, which is the default property of my class. Problem with that is returning the various fields in the correct data-type. I would like this to be as EASY to maintain as possible - if a structural change is made to the database, it would be NICE if the code didn't have to be changed, but this is not a necessity. Somebody out there must have dealt with this problem and come up with a nifty solution? B. Quote
Moderators Robby Posted May 24, 2005 Moderators Posted May 24, 2005 What about a Strongly Typed Dataset? Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.