|
-
Sep 17th, 2000, 08:24 PM
#1
Thread Starter
Addicted Member
Hi,
I have a collection which I want to populate with some Contact objects. Each contact object has properties such as name,address etc. and are stored in a SQl database. I loop through the recordset and populate each contact object before adding it to my collection!
However, when this is done, all the objects in the collection are exactly the same .
I have stepped through in debug mode and every time it adds a new contact object to the collection, it changes all the previous objects in the collection into the new object so that when it is finished, all the objects in the collection are equal to the last one added. Why?
Any help would be appreciated
Shaun
Web/Application Developer
VB6 Ent (SP5), Win 2000,SQL Server 2000
-
Sep 17th, 2000, 09:05 PM
#2
Lively Member
It sounds to me like you havent actually used a new object each time. If you havent used the new keyword each time you have been adding a new contact object to the collection then all you have been doing is adding pointers to contact obejects toe the collection. Since all of the pointers point to the same object, the data is the same. To get around this the easiest way would probly be to crate a seperate sub which creates a NEW contact object then adds it to the collection.
-
Sep 18th, 2000, 03:35 AM
#3
Thread Starter
Addicted Member
Thanks.
That was exactly what I was doing. Works fine now! 
Web/Application Developer
VB6 Ent (SP5), Win 2000,SQL Server 2000
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|