set oRS2 = oRS2 problems 
Author Message
 set oRS2 = oRS2 problems

Hi,
I have to loop through a recordset more than once and I'm having problems
using a disconnected recordset which enables me to loop through a recordset
more than once.  Therefore,  the setting i'm using are:
CursorLocation = adUseServer
CursorType = adOpenForwardOnly
LockType = adLockReadOnly

So what I'm doing is creating a second recordset and assigning it the first
recordset
eg:  Dim oRS2 As ADODB.Recordset: Set oRS2 = New ADODB.Recordset: Set oRS2 =
oRS1

However, when I loop through oRS2 and hit EOF, oRS1 is also at EOF !!!

This defeats the whole purpose.
Is there any way to:
1) oRS1.MoveFirst without using a disconnected recordset ?
2) assign oRS2 and loop through it without effecting oRS1 ?

TIA

jrm



Fri, 06 May 2005 23:21:54 GMT  
 set oRS2 = oRS2 problems
Jim,

First of all you probably do not have disconnected recordset. You cannot
have disconnected recordset, which was opened on server side. Second -  both
recordset variables point to the same recordset and, of course, both reflect
currect state of it. If recordset is in EOF position, then both variables
will shouw you. Second variable is not pointing to copy of recordset, it is
pointing to EXACT same recerdset.

1. Moving to the first record in recordset does not depend on disconnected
it or not. You could move pointer to the firat record in any kind of
recordset, even if forward-only. Just use MoveFirst method of recordset
2. If you need independent  recordset, then you need make a copy of it. You
could do that just opening another recordset based on same SELECT statement
or use next link with example with Stream object

http://www.able-consulting.com/ADO_Faq.htm#Q42

in that case both copies of recordset will use thgeir own navigation status

--
Val Mazur
Microsoft MVP


Quote:
> Hi,
> I have to loop through a recordset more than once and I'm having problems
> using a disconnected recordset which enables me to loop through a
recordset
> more than once.  Therefore,  the setting i'm using are:
> CursorLocation = adUseServer
> CursorType = adOpenForwardOnly
> LockType = adLockReadOnly

> So what I'm doing is creating a second recordset and assigning it the
first
> recordset
> eg:  Dim oRS2 As ADODB.Recordset: Set oRS2 = New ADODB.Recordset: Set oRS2
=
> oRS1

> However, when I loop through oRS2 and hit EOF, oRS1 is also at EOF !!!

> This defeats the whole purpose.
> Is there any way to:
> 1) oRS1.MoveFirst without using a disconnected recordset ?
> 2) assign oRS2 and loop through it without effecting oRS1 ?

> TIA

> jrm



Fri, 06 May 2005 23:44:19 GMT  
 set oRS2 = oRS2 problems
[...]

Quote:
> So what I'm doing is creating a second recordset and assigning it the first
> recordset

To be precise, you're assigning a reference to the first recordset. That
is, the second recordset *is* the first recordset.

Quote:
> eg:  Dim oRS2 As ADODB.Recordset: Set oRS2 = New ADODB.Recordset: Set oRS2 =
> oRS1

> However, when I loop through oRS2 and hit EOF, oRS1 is also at EOF !!!

Of course it is, since oRS1 *is* oRS2.

If you want to create a copy of the recordset, then

  Set oRS2 = oRS1.Clone()

hth

Adam
--
"I think it's a new feature. Don't tell anybody it was an accident."
                -- Larry Wall on s/foo/bar/eieio



Fri, 06 May 2005 23:46:33 GMT  
 set oRS2 = oRS2 problems
The set recordset2 = recordset1 does not create a copy of the recordset,
just a reference from RS1 to RS2....

If your looking to loop through the recordset a second time you will have to
change the cursor type from Forward Only to either a Dynamic type recordset
or a Statis recordset (Forward does not allow moving back through the
records since the records are deleted from the recordset when you move to
the next record)..

--
Veign
www.veign.com
<<NEW Link200 v2.0.2 Released>> - Bigger, Better, Cleaner!
www.veign.com/download_application.html#Link200
Code Samples & Sample Projects
http://www.veign.com/information/application/info_app.html
Submit Your Best Code (you keep the rights)
http://www.veign.com/information/application/code_submit.html
---------

Quote:
> Hi,
> I have to loop through a recordset more than once and I'm having problems
> using a disconnected recordset which enables me to loop through a
recordset
> more than once.  Therefore,  the setting i'm using are:
> CursorLocation = adUseServer
> CursorType = adOpenForwardOnly
> LockType = adLockReadOnly

> So what I'm doing is creating a second recordset and assigning it the
first
> recordset
> eg:  Dim oRS2 As ADODB.Recordset: Set oRS2 = New ADODB.Recordset: Set oRS2
=
> oRS1

> However, when I loop through oRS2 and hit EOF, oRS1 is also at EOF !!!

> This defeats the whole purpose.
> Is there any way to:
> 1) oRS1.MoveFirst without using a disconnected recordset ?
> 2) assign oRS2 and loop through it without effecting oRS1 ?

> TIA

> jrm



Sat, 07 May 2005 00:06:27 GMT  
 set oRS2 = oRS2 problems
Thanks Adam but when I use oRS2 = oRS1.Clone() i get an errors:
Current Recordset does not support bookmarks. This may be a limitation of
the provider or of the selected cursortype.
tried different cursortypes: adOpenForwardOnly, adOpenStatic



Quote:

> [...]
> > So what I'm doing is creating a second recordset and assigning it the
first
> > recordset

> To be precise, you're assigning a reference to the first recordset. That
> is, the second recordset *is* the first recordset.

> > eg:  Dim oRS2 As ADODB.Recordset: Set oRS2 = New ADODB.Recordset: Set
oRS2 =
> > oRS1

> > However, when I loop through oRS2 and hit EOF, oRS1 is also at EOF !!!

> Of course it is, since oRS1 *is* oRS2.

> If you want to create a copy of the recordset, then

>   Set oRS2 = oRS1.Clone()

> hth

> Adam
> --
> "I think it's a new feature. Don't tell anybody it was an accident."
>                 -- Larry Wall on s/foo/bar/eieio



Sat, 07 May 2005 00:15:01 GMT  
 set oRS2 = oRS2 problems
Hi,

Clone has some limitations depending on provider and cursor settings. But
anyway Clone does not create pure copy of recordset. Use example, which I
posted (with Stream object) to create real copy of recordset.

--
Val Mazur
Microsoft MVP


Quote:
> Thanks Adam but when I use oRS2 = oRS1.Clone() i get an errors:
> Current Recordset does not support bookmarks. This may be a limitation of
> the provider or of the selected cursortype.
> tried different cursortypes: adOpenForwardOnly, adOpenStatic




> > [...]
> > > So what I'm doing is creating a second recordset and assigning it the
> first
> > > recordset

> > To be precise, you're assigning a reference to the first recordset. That
> > is, the second recordset *is* the first recordset.

> > > eg:  Dim oRS2 As ADODB.Recordset: Set oRS2 = New ADODB.Recordset: Set
> oRS2 =
> > > oRS1

> > > However, when I loop through oRS2 and hit EOF, oRS1 is also at EOF !!!

> > Of course it is, since oRS1 *is* oRS2.

> > If you want to create a copy of the recordset, then

> >   Set oRS2 = oRS1.Clone()

> > hth

> > Adam
> > --
> > "I think it's a new feature. Don't tell anybody it was an accident."
> >                 -- Larry Wall on s/foo/bar/eieio



Sat, 07 May 2005 00:25:24 GMT  
 set oRS2 = oRS2 problems
Val,
What I'm saying is I'm not using a disconnected recordset.  If I do use a
disconnected recordset, I can movenext, moveprevious, etc. - no problems.
however, a disconnected recordset seems very slow.  I have a client app that
creates the oRS and passes it to a com+ component running in MTS.  When I
use a server side oRS it runs fast, when I chenge to client side, it runs
slow, so I was trying to use server side and a second oRS - a copy or clone
or whatever to enable me to move a second time through the same data.

jrm


Quote:
> Jim,

> First of all you probably do not have disconnected recordset. You cannot
> have disconnected recordset, which was opened on server side. Second -
both
> recordset variables point to the same recordset and, of course, both
reflect
> currect state of it. If recordset is in EOF position, then both variables
> will shouw you. Second variable is not pointing to copy of recordset, it
is
> pointing to EXACT same recerdset.

> 1. Moving to the first record in recordset does not depend on disconnected
> it or not. You could move pointer to the firat record in any kind of
> recordset, even if forward-only. Just use MoveFirst method of recordset
> 2. If you need independent  recordset, then you need make a copy of it.
You
> could do that just opening another recordset based on same SELECT
statement
> or use next link with example with Stream object

> http://www.able-consulting.com/ADO_Faq.htm#Q42

> in that case both copies of recordset will use thgeir own navigation
status

> --
> Val Mazur
> Microsoft MVP



> > Hi,
> > I have to loop through a recordset more than once and I'm having
problems
> > using a disconnected recordset which enables me to loop through a
> recordset
> > more than once.  Therefore,  the setting i'm using are:
> > CursorLocation = adUseServer
> > CursorType = adOpenForwardOnly
> > LockType = adLockReadOnly

> > So what I'm doing is creating a second recordset and assigning it the
> first
> > recordset
> > eg:  Dim oRS2 As ADODB.Recordset: Set oRS2 = New ADODB.Recordset: Set
oRS2
> =
> > oRS1

> > However, when I loop through oRS2 and hit EOF, oRS1 is also at EOF !!!

> > This defeats the whole purpose.
> > Is there any way to:
> > 1) oRS1.MoveFirst without using a disconnected recordset ?
> > 2) assign oRS2 and loop through it without effecting oRS1 ?

> > TIA

> > jrm



Sat, 07 May 2005 00:37:28 GMT  
 set oRS2 = oRS2 problems
Hi,

In that case you would need to open recordset in any another mode except
forward-only because forward-only will allow you to navigate forward
(MoveNext method) and use MoveFirst (which actually requires recordset), but
not MobePrevious. To get full navigation you would need to open recordset
for example as a dynamic

--
Val Mazur
Microsoft MVP


Quote:
> Val,
> What I'm saying is I'm not using a disconnected recordset.  If I do use a
> disconnected recordset, I can movenext, moveprevious, etc. - no problems.
> however, a disconnected recordset seems very slow.  I have a client app
that
> creates the oRS and passes it to a com+ component running in MTS.  When I
> use a server side oRS it runs fast, when I chenge to client side, it runs
> slow, so I was trying to use server side and a second oRS - a copy or
clone
> or whatever to enable me to move a second time through the same data.

> jrm



> > Jim,

> > First of all you probably do not have disconnected recordset. You cannot
> > have disconnected recordset, which was opened on server side. Second -
> both
> > recordset variables point to the same recordset and, of course, both
> reflect
> > currect state of it. If recordset is in EOF position, then both
variables
> > will shouw you. Second variable is not pointing to copy of recordset, it
> is
> > pointing to EXACT same recerdset.

> > 1. Moving to the first record in recordset does not depend on
disconnected
> > it or not. You could move pointer to the firat record in any kind of
> > recordset, even if forward-only. Just use MoveFirst method of recordset
> > 2. If you need independent  recordset, then you need make a copy of it.
> You
> > could do that just opening another recordset based on same SELECT
> statement
> > or use next link with example with Stream object

> > http://www.able-consulting.com/ADO_Faq.htm#Q42

> > in that case both copies of recordset will use thgeir own navigation
> status

> > --
> > Val Mazur
> > Microsoft MVP



> > > Hi,
> > > I have to loop through a recordset more than once and I'm having
> problems
> > > using a disconnected recordset which enables me to loop through a
> > recordset
> > > more than once.  Therefore,  the setting i'm using are:
> > > CursorLocation = adUseServer
> > > CursorType = adOpenForwardOnly
> > > LockType = adLockReadOnly

> > > So what I'm doing is creating a second recordset and assigning it the
> > first
> > > recordset
> > > eg:  Dim oRS2 As ADODB.Recordset: Set oRS2 = New ADODB.Recordset: Set
> oRS2
> > =
> > > oRS1

> > > However, when I loop through oRS2 and hit EOF, oRS1 is also at EOF !!!

> > > This defeats the whole purpose.
> > > Is there any way to:
> > > 1) oRS1.MoveFirst without using a disconnected recordset ?
> > > 2) assign oRS2 and loop through it without effecting oRS1 ?

> > > TIA

> > > jrm



Sat, 07 May 2005 00:50:00 GMT  
 set oRS2 = oRS2 problems
Check if the recordset is empty


Sat, 07 May 2005 21:25:43 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. form-level keyboard handler problem (set problem = me?)

2. set db=currentdb() "type mismatch problem"

3. Problem with setting INDEX on FoxPro table in Access 97

4. Problems setting a fields DisplayControl property

5. Problems setting Registry (Access 2.0 / NT4.0)

6. Set Control Value on Group Header-Page Break Problem

7. Problems with Set-up wizard and long file names

8. MyTable.Index problem setting

9. problem setting field size

10. Setting the SaveSentMessageFolder problem

11. Problem setting bookmarks

12. Multihomed server Setting problem for Dns and Exchange client

 

 
Powered by phpBB® Forum Software