|
 |
asp_databases thread: Changing the Command object's cursor type??
Message #1 by "Myron Fuller" <myronfuller@c...> on Mon, 26 Aug 2002 16:07:03
|
|
Hi, I was wondering if anyone could tell me how to change the cursor type
of the recordset returned by the Command object after you use it's Execute
method? I can't seem to find any literature describing how to do this.
Thanks!
Myron
Message #2 by "Ken Schaefer" <ken@a...> on Tue, 27 Aug 2002 11:20:05 +1000
|
|
You can't. Check the documentation, it is quite helpful in this regard:
http://msdn.microsoft.com/library/?url=/library/en-us/ado270/htm/mdprocursor
type.asp?frame=true
<quote>
The CursorType property is read/write when the Recordset is closed and
read-only when it is open
</quote>
You need to set the cursor type *before* you call .Execute, or when you call
.Execute. Why do you need to change the cursor type anyway?
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Myron Fuller" <myronfuller@c...>
Subject: [asp_databases] Changing the Command object's cursor type??
: Hi, I was wondering if anyone could tell me how to change the cursor type
: of the recordset returned by the Command object after you use it's Execute
: method? I can't seem to find any literature describing how to do this.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Message #3 by myronfuller@c... on Tue, 27 Aug 2002 15:07:48 -0400
|
|
I needed to have a way to fully navigate the recordset
that the Command object was returning. Maybe I'm wrong in saying this but
it seems that with ADO the only way to execute a query with parameters is
through the Command object but then it seems to be forward-only. I need
something I can move forward and backward through, I don't even really need
to update any of the information.
Chuck
----- Original Message -----
From: "Ken Schaefer" <ken@a...>
To: "ASP Databases" <asp_databases@p...>
Sent: Monday, August 26, 2002 9:20 PM
Subject: [asp_databases] Re: Changing the Command object's cursor type??
> You can't. Check the documentation, it is quite helpful in this regard:
>
http://msdn.microsoft.com/library/?url=/library/en-us/ado270/htm/mdprocursor
> type.asp?frame=true
>
> <quote>
> The CursorType property is read/write when the Recordset is closed and
> read-only when it is open
> </quote>
>
> You need to set the cursor type *before* you call .Execute, or when you
call
> .Execute. Why do you need to change the cursor type anyway?
>
> Cheers
> Ken
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> From: "Myron Fuller" <myronfuller@c...>
> Subject: [asp_databases] Changing the Command object's cursor type??
>
>
> : Hi, I was wondering if anyone could tell me how to change the cursor
type
> : of the recordset returned by the Command object after you use it's
Execute
> : method? I can't seem to find any literature describing how to do this.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
Message #4 by "Ken Schaefer" <ken@a...> on Wed, 28 Aug 2002 12:12:30 +1000
|
|
If you need to "forward" and "backwards" have you considered using .GetRows?
<%
Set objRS = objCommand.Execute()
If not objRS.EOF then
arrResults = objRS.GetRows
End If
'
' Dispose of all ADO objects now!
'
If isArray(arrResults) then
' We have results
Else
' We have no results
End If
%>
This way:
a) you can avoid expensive cursors like adOpenStatic
b) you can keep using adOpenForwardOnly, you can also use your command
objects
c) you can dispose of your recordset/command/connection objects as soon as
you get your data, you don't need to keep them open until the point where
you need to use the data
d) the vbScript array (arrResults) allows you to not only "scroll", but to
pull any arbitrary record from the resultset without having to scroll to the
appropriate record
In a web environment, you really want to avoid using cursors and iterating
recordsets etc as much as possible to ensure that you app has maximum
scalability.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <myronfuller@c...>
Subject: [asp_databases] Re: Changing the Command object's cursor type??
: I needed to have a way to fully navigate the recordset
: that the Command object was returning. Maybe I'm wrong in saying this but
: it seems that with ADO the only way to execute a query with parameters is
: through the Command object but then it seems to be forward-only. I need
: something I can move forward and backward through, I don't even really
need
: to update any of the information.
:
: Chuck
: ----- Original Message -----
: From: "Ken Schaefer" <ken@a...>
: To: "ASP Databases" <asp_databases@p...>
: Sent: Monday, August 26, 2002 9:20 PM
: Subject: [asp_databases] Re: Changing the Command object's cursor type??
:
:
: > You can't. Check the documentation, it is quite helpful in this regard:
: >
:
http://msdn.microsoft.com/library/?url=/library/en-us/ado270/htm/mdprocursor
: > type.asp?frame=true
: >
: > <quote>
: > The CursorType property is read/write when the Recordset is closed and
: > read-only when it is open
: > </quote>
: >
: > You need to set the cursor type *before* you call .Execute, or when you
: call
: > .Execute. Why do you need to change the cursor type anyway?
: >
: > Cheers
: > Ken
: >
: > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: > From: "Myron Fuller" <myronfuller@c...>
: > Subject: [asp_databases] Changing the Command object's cursor type??
: >
: >
: > : Hi, I was wondering if anyone could tell me how to change the cursor
: type
: > : of the recordset returned by the Command object after you use it's
: Execute
: > : method? I can't seem to find any literature describing how to do
this.
: >
: > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
 |