Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: collections VB.NET Data , +
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 19:42pm
Woogie2333
Edited 10-Jul-13 21:10pm
Maciej Los151.6K
v4
Comments
Sergey Alexandrovich Kryukov at 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 at 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 at 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 ;)
Rate this: bad
good
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 Wink | ;)
Have a look here:
Tutorial 1: Creating a Data Access Layer[^]
Data Access Layer (Part I)[^]
A Generic Data Access Layer in VB.Net[^]
  Permalink  
Comments
Woogie2 at 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
good
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
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 7,800
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,790


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 19 Jul 2013
Copyright © CodeProject, 1999-2014
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