473,549 Members | 2,346 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Embedded Hashtables

Does anyone know the proper method to save information to embedded
hashtables.

I am trying to save parent/child information to hashtables but I am not
getting the correct results I have made a very simplified example of
problem with the following code:

Dim cust As New Hashtable
Dim invoice As New Hashtable
Dim invoiceLines As New Hashtable
invoiceLines.Ad d(1, "500")
invoiceLines.Ad d(2, "1000")
invoice.Add("In v123", invoiceLines)
cust.Add("ABC", invoice)
invoiceLines.Cl ear()
invoice.Clear()
invoiceLines.Ad d(1, "123")
invoiceLines.Ad d(2, "10")
invoice.Add("In v222", invoiceLines)
cust.Add("BBB", invoice)

Is there a way to correctly save this information so that it doesn't delete
the values of the first hashtables that I want saved into the cust hashtable
when I do a clear?

Thanks,
Curtis
Nov 21 '05 #1
1 1506
I solved my problem by using the .clone method of the hashtables like so:

Dim cust As New Hashtable
Dim invoice As New Hashtable
Dim invoiceLines As New Hashtable
invoiceLines.Ad d(1, "500")
invoiceLines.Ad d(2, "1000")
invoice.Add("In v123", invoiceLines.Cl one)
cust.Add("ABC", invoice.Clone)
invoiceLines.Cl ear()
invoice.Clear()
invoiceLines.Ad d(1, "123")
invoiceLines.Ad d(2, "10")
invoice.Add("In v222", invoiceLines.Cl one)
cust.Add("BBB", invoice.Clone)

Curtis

"Curtis" <cs*****@hotmai l.com> wrote in message
news:u$******** ******@tk2msftn gp13.phx.gbl...
Does anyone know the proper method to save information to embedded
hashtables.

I am trying to save parent/child information to hashtables but I am not
getting the correct results I have made a very simplified example of
problem with the following code:

Dim cust As New Hashtable
Dim invoice As New Hashtable
Dim invoiceLines As New Hashtable
invoiceLines.Ad d(1, "500")
invoiceLines.Ad d(2, "1000")
invoice.Add("In v123", invoiceLines)
cust.Add("ABC", invoice)
invoiceLines.Cl ear()
invoice.Clear()
invoiceLines.Ad d(1, "123")
invoiceLines.Ad d(2, "10")
invoice.Add("In v222", invoiceLines)
cust.Add("BBB", invoice)

Is there a way to correctly save this information so that it doesn't
delete the values of the first hashtables that I want saved into the cust
hashtable when I do a clear?

Thanks,
Curtis

Nov 21 '05 #2

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

Similar topics

0
1431
by: Aaron | last post by:
I am not sure the appropriate newsgroup for this question,...I have also posted this on the XML.SOAP foru Within a VB.NET application, I have two objects that are serializable. The second object contains a string variable containing the SOAP Serialized XML of the first object. If I serialize the second object into a string, I get very strange...
6
2280
by: Michael Schollmeyer | last post by:
Hello, The following code writes the text string: Uri uri1 = new Uri("http://www.here.net/aplace?param=one"); Uri uri2 = new Uri("http://www.here.net/aplace?param=two"); int h1 = uri1.GetHashCode(); int h2 = uri2.GetHashCode(); bool e = uri1.Equals(uri2); if (e == true && h1 != h2)
13
1769
by: Anders Borum | last post by:
Hello! Now that generics are introduces with the next version of C#, I was wondering what kind of performance gains we're going to see, when switching from e.g. the general hashtable to a hashtable that supports (or implements) generics? I haven't tried generics hands-on, but I would assume that once you don't have to do casting anymore,...
4
8345
by: Anders Borum | last post by:
Hello! I have a list of singleton classes (model managers) that store objects internally using hashtables. Each of these classes use a single hashtable to store e.g. users, pages, elements and so on (I have complete control of the objects stored). I am currently using a set of abstract cache classes that my model managers subclass. The...
2
3139
by: PAzevedo | last post by:
I have this Hashtable of Hashtables, and I'm accessing this object from multiple threads, now the Hashtable object is thread safe for reading, but not for writing, so I lock the object every time I need to write to it, but now it occurred to me that maybe I could just lock one of the Hashtables inside without locking the entire object, but...
7
2668
by: Kamran Shafi | last post by:
Hi, I am creating an arraylist (say masterArrayList) of hashtables, where each hashtable (say table) is of the format key=string, value = arraylist of strings (say existing_strings). In a foreach loop I retreive the corresponding hashtable from the masterArrayList and add new strings to existing_strings after comparing the hashtable keys. ...
7
1952
by: Mike P | last post by:
I have 2 hashtables each of which I am using to store a set of IDs and Descriptions. Hashtable 1 will have the full set of data (e.g. IDs 1,2,3,4,5) whereas Hashtable 2 will only have a subset of that data (e.g. IDs 2,4). What I want to do is to iterate through Hashtable 1 (using foreach?) checking if each ID/Description is in Hashtable 2,...
0
2861
by: John Smith | last post by:
Hello people, I have a performance query regarding LINQ that I would like some opinions. Currently we have a business logic framework that is used in n-tier applications. We read data from a database using a data reader and use this information to populate a set of business objects. Our business data is identified by a GUID so we...
0
1445
by: Jake McCool | last post by:
Hello people, I have a performance query regarding LINQ that I would like some opinions. Currently we have a business logic framework that is used in n-tier applications. We read data from a database using a data reader and use this information to populate a set of business objects. Our business data is identified by a GUID so we...
0
7471
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7985
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6071
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5387
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5111
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3517
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3496
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1962
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.