|
-
Jun 3rd, 2003, 10:24 PM
#1
Thread Starter
Addicted Member
Best way to retrive data from database trough a class?
Hi
I was just wondering whats is the best way to retrive data from a database trough a class and return it to the calling client, so far i can only think of two
1)Retrive data from a database trough a dataadapter and return as datatable.
2)Retrive data from a database trough dataadapter and assign the return data to the properties of the class, so that the calling client can get the data trough the properties of the class.
Is there any better way then the one stated above?
Thanks
-
Jun 13th, 2003, 12:46 AM
#2
New Member
You can do either of those methods.
You could also use a DataReader which is faster, Particularly if you are storing them in member variables in your class.
You could also create a strongly typed dataset and use a dataadapter to populate a class inherited from your typed ds.
-
Jun 13th, 2003, 08:01 AM
#3
Addicted Member
...agree with skaterx2 , either method is valid
method 2 is the 'traditional' way to do it as it fits nicely into the OOP model and diagrams up nicely if your using UML i.e. 1 stateless class per table. Java programmers have traditionally used this method.
BUT...
to be honest this method can get messy - loading objects via properties, providing collection classes as containers for these objects etc. etc. can make for excess work, AND no doubt will have a performance overhead. I would, personally, go with method 1. Even though in 'pure' OO design terms it might not be quite right.
PS.
In my latest project i fought for using method 1, but we ended up going with what essentially is your method 2 - i am sooo glad i lost!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|