Click here to Skip to main content
13,055,884 members (48,143 online)
Rate this:
Please Sign up or sign in to 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
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 10-Jul-13 18:42pm
Updated 10-Jul-13 20:10pm
Maciej Los255.3K
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.
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

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 - Yes, they do, but this is our job to explain them that is bad idea ;)
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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[^]
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 :-)
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 19 Jul 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100