Key for recordset in recordsets collection 
Author Message
 Key for recordset in recordsets collection

Can anyone tell me the variant or string key to a recordset in the db
recordsets collection?  I need to store the key as a property in an
object representing a row in the recordset for subsequent potential
update.  I cannot store the ordinal position of the recordset in the
collection, as it is my understanding that this can change with
subsequents additions or removals of recordsets in the recordsets
collection.

Any help would be greatly appreciated.
Thanks.
jon



Sat, 20 Mar 1999 03:00:00 GMT  
 Key for recordset in recordsets collection

As long as you do not close that recordset.  Look for help on
Bookmarks.  They will uniquely identify a row in a recordset until
that recordset is closed.  Cloned recordsets share common bookmarks.
This is very useful for operations (affecting current record) on one
recordset that will not affect the original.

As for the representation of the bookmark.  If I remember correctly,
these are stored as binary data (VB 4.0) and have no significant
meaning -- visually.


Quote:
>Can anyone tell me the variant or string key to a recordset in the db
>recordsets collection?  I need to store the key as a property in an
>object representing a row in the recordset for subsequent potential
>update.  I cannot store the ordinal position of the recordset in the
>collection, as it is my understanding that this can change with
>subsequents additions or removals of recordsets in the recordsets
>collection.

>Any help would be greatly appreciated.
>Thanks.
>jon



Sat, 20 Mar 1999 03:00:00 GMT  
 Key for recordset in recordsets collection


Quote:
>As long as you do not close that recordset.  Look for help on
>Bookmarks.  They will uniquely identify a row in a recordset until
>that recordset is closed.  Cloned recordsets share common bookmarks.
>This is very useful for operations (affecting current record) on one
>recordset that will not affect the original.

This is a good answer, but it's answering a question other than that

Quote:
>>Can anyone tell me the variant or string key to a recordset in the db
>>recordsets collection?  I need to store the key as a property in an
>>object representing a row in the recordset for subsequent potential
>>update.  I cannot store the ordinal position of the recordset in the
>>collection, as it is my understanding that this can change with
>>subsequents additions or removals of recordsets in the recordsets
>>collection.

If I understand this properly, you've created a class of objects that
is to contain records, and you have code that will be processing these
objects without knowing what recordset each record is in.  So you want to
make the key to the recordset (in the database's Recordsets collection) a
property of your object.  Right?

My first impression is, gee, I'd think long and hard about whether or not
this was the best possible way to design this application, but I'll assume
you've already done this.

I haven't tried this myself, but I would bet that the key is the Name
property of the Recordset object.  If this were true, you could store the
Name in your object and get back to the recordset that way.

But really, why not just make a Recordset object one of the properties of
your class?  That way you can just do

   Set MyObject.Source = rsSourceRecordset

and then have your method do a Source.Update or whatever it needs to do.

An object variable is just a four-byte pointer, so there's less memory
overhead than there is in storing the key.  And it's a direct reference,
so there's less processing overhead than there is in storing the key.  
And even if you store the key, when you do the

   Set rsTemp = dbMain.Recordsets(sKey)

you're just setting rsTemp to the same four-byte pointer that you would
have set it to if you'd just set rsTemp to the recordset in the first
place and been done with it.

Does this make sense?

Bob Rossney



Tue, 23 Mar 1999 03:00:00 GMT  
 Key for recordset in recordsets collection

The first thing I look for is a unique, non-null, field from the
recordset that must also be added from the gui when a new member is
added to the collection. Good luck. Sometimes a display name or a user
generated code fits the bill.

Second, create a random number and make it the key with cstr().

Third, don't make a key. Move through the collection using the item
method and use the item method to point to the current member when
needed. I have found this useful within a collection class and
dependent collection when there are many properties, but none fit the
first item above.

Bob.

I hardly ever use bound controls. And these days we are using ole
servers to connect to databases and pass the data back to the client.
The server puts the recordset or rdoresultset into variant arrays and
sends the arrays to the client. The client takes the data from the
array and puts it into collections. After the collection members have
been added, removed, revised, and deleted, the data is then put back
into variant arrays and passed back to the server and processed into
the database. This requires more coding, but provides a lot of control
along with many other oo advantages.

Quote:


>>As long as you do not close that recordset.  Look for help on
>>Bookmarks.  They will uniquely identify a row in a recordset until
>>that recordset is closed.  Cloned recordsets share common bookmarks.
>>This is very useful for operations (affecting current record) on one
>>recordset that will not affect the original.
>This is a good answer, but it's answering a question other than that

>>>Can anyone tell me the variant or string key to a recordset in the db
>>>recordsets collection?  I need to store the key as a property in an
>>>object representing a row in the recordset for subsequent potential
>>>update.  I cannot store the ordinal position of the recordset in the
>>>collection, as it is my understanding that this can change with
>>>subsequents additions or removals of recordsets in the recordsets
>>>collection.
>If I understand this properly, you've created a class of objects that
>is to contain records, and you have code that will be processing these
>objects without knowing what recordset each record is in.  So you want to
>make the key to the recordset (in the database's Recordsets collection) a
>property of your object.  Right?
>My first impression is, gee, I'd think long and hard about whether or not
>this was the best possible way to design this application, but I'll assume
>you've already done this.
>I haven't tried this myself, but I would bet that the key is the Name
>property of the Recordset object.  If this were true, you could store the
>Name in your object and get back to the recordset that way.
>But really, why not just make a Recordset object one of the properties of
>your class?  That way you can just do
>   Set MyObject.Source = rsSourceRecordset
>and then have your method do a Source.Update or whatever it needs to do.
>An object variable is just a four-byte pointer, so there's less memory
>overhead than there is in storing the key.  And it's a direct reference,
>so there's less processing overhead than there is in storing the key.  
>And even if you store the key, when you do the
>   Set rsTemp = dbMain.Recordsets(sKey)
>you're just setting rsTemp to the same four-byte pointer that you would
>have set it to if you'd just set rsTemp to the recordset in the first
>place and been done with it.
>Does this make sense?
>Bob Rossney





Thu, 25 Mar 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Opened Recordsets don't show up in Recordsets Collection

2. recordset fields collection - ado

3. Newbie question regarding Recordsets collection

4. MS Access:Using a time in a FindFirst criteria operating on a Recordset collection

5. Collection to ADO recordset?

6. recordset fields collection - ado

7. recordset error - Item not found in this collection

8. collections vs ado recordsets?

9. Recordsets Collection

10. Collection Acting Like ADO Recordset

11. Collections vs Recordsets

12. Recordset error - item not found in this collection

 

 
Powered by phpBB® Forum Software