473,405 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Need help storing data

Hello all,

I am a VB.NET beginner who is unfamilier with all the different
collection types that VB.NET has to offer. I am in need of a way to
store multiple elements which can be retrieved with a unique key
(string). For example, I would like to store characteristics like first
name, last name, age, and phone number and associate them with the
unique key like a USERID. Then loop through the data collection and
pull certain elements out for processing. Which collection type would
be best suited for this purpose?

Thanks!

Nov 21 '05 #1
5 1986
Paulers,

The Hashtable is a collection that implements key/value storage.

Kerry Moorman
"Paulers" wrote:
Hello all,

I am a VB.NET beginner who is unfamilier with all the different
collection types that VB.NET has to offer. I am in need of a way to
store multiple elements which can be retrieved with a unique key
(string). For example, I would like to store characteristics like first
name, last name, age, and phone number and associate them with the
unique key like a USERID. Then loop through the data collection and
pull certain elements out for processing. Which collection type would
be best suited for this purpose?

Thanks!

Nov 21 '05 #2
Paulers,

As you say it already in your message you need a table for your data that
can have a primary key.

In other words the "datatable".

I hope this helps,

Cor
Nov 21 '05 #3
"Paulers" <Su*******@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I am in need of a way to store multiple elements which can be
retrieved with a unique key (string). For example, I would like to
store characteristics like first name, last name, age, and phone number
and associate them with the unique key like a USERID. Then loop
through the data collection and pull certain elements out for
processing. Which collection type would be best suited for this purpose?


/Any/ of them really, because what you'll be placing into the "collection"
is a class of your own devising that contains all these properties.

HashTable is probably the easiest, though.

Public Class Person
Public Sub New( Username as String, ...
Public ReadOnly Property Age() as Integer
Public Property DoB() as DateTime
Public Property Forename() as String
Public Property Phone() as String
Public Property Surname() as String
Public ReadOnly Property Username() as String
End Class

Dim htPeople as New HashTable

htPeople.Add( "fred", New Person( "fred", ... ) )

Dim employee as Person _
= DirectCast( htPeople.Item( "fred" ), Person )

Bear in mind, though, that some collections hold things internally
as DictionaryEntry objects, so you might have to do an extra layer
of "translation" when iterating through the items therein.

HTH,
Phill W.
Nov 21 '05 #4
Thanks for the example! Can I talk you into an example showing how to
retrieve the information from the HashTable? I really appreciate the
help.

Nov 21 '05 #5
I understand that you are storing objects in the collection, but in the
Person Class how are the properties getting set? I see the declaration
but I dont see set and get methods. Do I need them in the example
above? Don't I have to define the values of each property?

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Eben Goodman | last post by:
I am storing book isbn numbers in a table. isbn numbers are 10 digit numbers and many start with 0. The data type of the field I am storing this info in is a bigint(16) unsigned. It appears that...
5
by: Don Vaillancourt | last post by:
I'm building a system when one can upload a document to the website. I will be storing the document on the hard-drive for quick/easy access, but I was also thinking of storing it in an existing...
1
by: VMI | last post by:
Is it possible to store the data in a datatable in the hard disk instead of the memory? By default, when a datatable's being filled, the table (and data) will remain in memory. Would it be possible...
2
by: jakk | last post by:
Below is the exception that Iam getting. It says that the DataView that Iam storing in the session is not Serializable. BUt works fine if I store in the inproc session and fails if I switch to...
6
by: Mudcat | last post by:
Hi, I am trying to build a tool that analyzes stock data. Therefore I am going to download and store quite a vast amount of it. Just for a general number - assuming there are about 7000 listed...
6
by: Kyle Teague | last post by:
What would give better performance, serializing a multidimensional array and storing it in a single entry in a table or storing each element of the array in a separate table and associating the...
24
by: kdotsky | last post by:
Hello, I am using some very large dictionaries with keys that are long strings (urls). For a large dictionary these keys start to take up a significant amount of memory. I do not need access to...
20
by: Martin Jørgensen | last post by:
Hi, I'm reading a number of double values from a file. It's a 2D-array: 1 2 3 4 5 6 7 ------------- 1 3.2 2 0 2.1 3 9.3 4
4
by: Falcolas | last post by:
I personally feel that it's a bad idea. I've got to convince managerial types of this. Would some of you mind posting comments for and against the concept of storing data in XML attributes? If...
3
by: Annonymous Coward | last post by:
I remember readng that BLOBs can be stored externally (with reference to the BLOB file stored in tables instead). Does anyone have any experience doing this ? I have a few questions: 1).what...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.