Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
OK - I've read and I've played around and I keep coming up blank with topics that almost get there but don't

Two of my classes in my VB2010 learning project are: "Project" and "Objective"

Both are stored in related data tables where each Objective has a Project_ID (a one-to-many relationship)

I want to incorporate an "Objectives" collection as a Property of the Projects class. I'm thinking I would populate that with a myProject.PopulateObjectives method calling
SQL
Select* from Objectives WHERE Project_ID=[@Project_ID]

and that would allow me then to do a number of calculations and iterations with that project (and other projects)

How do I declare the Property and Methods for this?

All help gratefully received
Posted
Updated 10-Jul-13 20:10pm
v4
Comments
Sergey Alexandrovich Kryukov 11-Jul-13 0:52am    
First of all, don't tag it "VB", tag "VB.NET", not too confuse these very different languages.
By Microsoft naming conventions, a class should have a singular noun name: "Project", "Objective".
The question is not clear: what are your concerns? If you don't know how to define properties and methods, read about it: these are very basics of programming, it's no good to try to learn it from forums. Read the documentation/manual/tutorial/textbook.
—SA
Woogie2 11-Jul-13 1:34am    
My bad, I accidentally pluralised the class names on here and when I tagged I didn't see the offer of VB.Net - do people still use VB not.net?

Declarations are basics - sure - but declaring a property with a collection of objects as values - is proving not to be for me after reading multiple sources (as stated in the first sentence).

I will try to make the question a little more definitive though
Maciej Los 11-Jul-13 2:09am    
do people still use VB not.net? - Yes, they do, but this is our job to explain them that is bad idea ;)

There is too many things to explain... Only one suggestion: use Data Access Layer to return data from database ;)
Have a look here:
Tutorial 1: Creating a Data Access Layer[^]
Data Access Layer (Part I)[^]
A Generic Data Access Layer in VB.Net[^]
 
Share this answer
 
Comments
Woogie2 11-Jul-13 2:23am    
Thanks - I have actually taken on board the first comment and will try to narrow down what keeps going wrong. It seems whichever way I turn on this I get errors and I didn't want to go through them all. Never know - in the process I may get it to go right! I'll check those tutorials though - cheers :-)
What I was missing here was that I needed to a) declare a property called Objectives as a collection/list of Objective b) set up a call to populate the objectives and c) set up a sub topopulate objectives using a query restricted to that projectID

The data layer tutorial proposed by Maciej was very useful

Sometimes people don't know what they don't know
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900