PC Review


Reply
Thread Tools Rate Thread

Collection of a class to use as worktable

 
 
Reynaert Kristien
Guest
Posts: n/a
 
      15th Mar 2010
Hi,

I need some kind of unbound table in which i can add and edit items
I must be able to read items by ID and update some fieldvalues.
At the end of the program i will have to read all items of this table and
use the values to update some "real" (other) tables
So i need some kind of 'worktable' to store my data temporary

I think i have to make a class in which i define my fields of my worktable
and then work with some collection of that class, but i don't quite know
exactly how to do this

Someone who can give me some hints in what i should use?
Thanks,
Kristien

 
Reply With Quote
 
 
 
 
Tom Shelton
Guest
Posts: n/a
 
      15th Mar 2010
On 2010-03-15, Reynaert Kristien <(E-Mail Removed)> wrote:
> Hi,
>
> I need some kind of unbound table in which i can add and edit items
> I must be able to read items by ID and update some fieldvalues.
> At the end of the program i will have to read all items of this table and
> use the values to update some "real" (other) tables
> So i need some kind of 'worktable' to store my data temporary
>
> I think i have to make a class in which i define my fields of my worktable
> and then work with some collection of that class, but i don't quite know
> exactly how to do this
>
> Someone who can give me some hints in what i should use?
> Thanks,
> Kristien
>


Sounds an awful lot like a dataset to me... You can create and setup a
dataset in memory.

--
Tom Shelton
 
Reply With Quote
 
Mr. Arnold
Guest
Posts: n/a
 
      15th Mar 2010


"Reynaert Kristien" wrote:

> Hi,
>
> I need some kind of unbound table in which i can add and edit items
> I must be able to read items by ID and update some fieldvalues.
> At the end of the program i will have to read all items of this table and
> use the values to update some "real" (other) tables
> So i need some kind of 'worktable' to store my data temporary
>
> I think i have to make a class in which i define my fields of my worktable
> and then work with some collection of that class, but i don't quite know
> exactly how to do this
>
> Someone who can give me some hints in what i should use?
> Thanks,
> Kristien
>


You would have a public class with public properties.

<http://www.vbdotnetheaven.com/Uploadfile/rajeshvs/PropertiesInVbDotNet04192005060237AM/PropertiesInVbDotNet.aspx>

You would instanciate the class new an object and set the object's public
properties each time.


You can use a List<T> a collection.

dim myobjects = new List<MyObject>

If the object/class was named MyObject, then in some kind of loop to load
the object into the collection.

dim obj = new MyObject

obj.ID = 1
obj.Name = "help"

myobjects.add(myobjects)

Now MyObject iis in a collection of objects myobjects.

If you have .Net 3.0 Framework or better, the you can use Linq to query the
collection for a MyObject in myobjects by ID as an example and make the
chenges to the object.

If you don't have Linq, then you'll need to make an function or method to
address the object in the collection using a foreach loop
..
foreach(myobject in myobjects)

if myobejct.ID = passedID then
myobject.Name = "Help"
endif

You would walk the collection using a loop to read each object in the
collection to sent to a SQL table or whatever.

foreach(myobject in myobjects)

TableNameField = myobject.Name

It's an example of of OOP's Object Oriented Programming.

You don't need a worktable, but instead you need to understand OOP's,
gernerics and collections.







 
Reply With Quote
 
Harry Strybos
Guest
Posts: n/a
 
      15th Mar 2010
"Reynaert Kristien" <(E-Mail Removed)> wrote in message
news:0B0AE005-D956-43F6-9B7D-(E-Mail Removed)...
> Hi,
>
> I need some kind of unbound table in which i can add and edit items
> I must be able to read items by ID and update some fieldvalues.
> At the end of the program i will have to read all items of this table and
> use the values to update some "real" (other) tables
> So i need some kind of 'worktable' to store my data temporary
>
> I think i have to make a class in which i define my fields of my worktable
> and then work with some collection of that class, but i don't quite know
> exactly how to do this
>
> Someone who can give me some hints in what i should use?
> Thanks,
> Kristien
>

Have you thought of using a Dictionary. You add the classes to the
dictionary and use your ID field as the key.
So you would have something like: MyDictionary("1234").FieldOne etc

 
Reply With Quote
 
Reynaert Kristien
Guest
Posts: n/a
 
      16th Mar 2010

"Reynaert Kristien" <(E-Mail Removed)> wrote in message
news:0B0AE005-D956-43F6-9B7D-(E-Mail Removed)...
> Hi,
>
> I need some kind of unbound table in which i can add and edit items
> I must be able to read items by ID and update some fieldvalues.
> At the end of the program i will have to read all items of this table and
> use the values to update some "real" (other) tables
> So i need some kind of 'worktable' to store my data temporary
>
> I think i have to make a class in which i define my fields of my worktable
> and then work with some collection of that class, but i don't quite know
> exactly how to do this
>
> Someone who can give me some hints in what i should use?
> Thanks,
> Kristien
>


----

Thank you for all the suggestions
I think Dictionary will be the best and easiest to use in my project.
As like with List<T>, i can work with a public class to put my values, and
it's easy to add, edit and iterate in the dictionary

I have .Net Framework 3.5 so if using list<T> i could use Linq to retreive
data. But i was struggling with the syntax to find the best way to edit a
value of an object
I would do it like:
Dim record As MyObject= (From myObject In myList _
Where myObject.[ID].Equals("aaa") _
Select myObject).SingleOrDefault()
If record IsNot Nothing Then
record.field1= True
End If
But as i found in definition of Select that parameters are ByVal, i don't
understand that my object in the list would be changed as i don't see that
'record' is a reference to my object. i didn't try it out though

Anyways, thank you all for your time to help me to move on with my project

Kristien


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding class object to collection repeats same object through collection? Erazmus Microsoft Excel Programming 2 17th Sep 2007 04:35 AM
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen Microsoft Dot NET 1 18th May 2007 10:24 AM
Can't get collection to save when using collection of custom class as property of control in VS 2005 J.Edwards Microsoft Dot NET Compact Framework 0 10th Jan 2006 04:44 AM
Class X Creates Collection of Instances of Class Y. Y's need info from X Jim Frazer Microsoft C# .NET 3 16th Jun 2004 09:17 AM
RaiseEvent from a class contained in a 2nd class collection? Andrew Microsoft Excel Programming 2 6th Jan 2004 04:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:49 PM.