Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 30th, 2004, 06:06 PM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hcweb
Default Change Cursor Type When Using the Command Object

Hello all!

I'm using the command object referenced in chapter 14 of Beginning Active Server Pages 3.0. Everything runs and returns correctly using this code.
<%
  Option Explicit
  Dim strConnect, strParcel, CYear, Cyear1
  strParcel = "0808E-02-059.000"
  CYear = Year(Now()) - 1
  CYear1 = Year(Now()) - 2
%>

<!-- METADATA TYPE="typelib"
              FILE="c:\program files\common files\system\ado\msado15.dll" -->
<%
  Dim objRS, objComm

  Set objComm = Server.CreateObject("ADODB.Command")
  objComm.ActiveConnection = strConnect
  objComm.CommandText = "SELECT ppin, parcel_number FROM ITDLRC01 WHERE parcel_number = '" & strParcel & "'" & _
                        " AND tax_year = " & CYear
  objComm.CommandType = adCmdText
  Set objRS = objComm.Execute
  Set objComm = Nothing

  If objRS.EOF Then
    Response.Write "Nothing Found"
  Else
  Do While Not objRS.EOF
    Response.Write objRS("ppin") & "<br>"
  objRS.MoveNext
  Loop
  End If

  objRS.Close
  Set objRS = Nothing
%>

What I would like to be able to do is change the cursor type to obtain the last record found. I've done some searching on this, and here's what I found.

"If you need to use a command, and require a different cursor or lock type, then you should use the Open method of the Recordset, but use the Command as the source of the Recordset. For example:

  cmdAuthors.ActiveConnection = strConn
  cmdAuthors.CommandText = "Authors"
  cmdAuthors.CommandType = adCmdTable
  rsAuthors.Open cmdAuthors, , adOpenDynamic, adLockOptimistic"

However, when I try to use this method I get an error "Object Required:" with no specification.

Please help!!!
 
Old April 6th, 2004, 08:44 PM
Authorized User
 
Join Date: Jan 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Hcweb,

I was looking for the same thing, but I came across this at Microsoft:
http://msdn.microsoft.com/library/de...asp?frame=true

Using the Execute method on a Connection object executes whatever query you pass to the method in the CommandText argument on the specified connection. If the CommandText argument specifies a row-returning query, any results that the execution generates are stored in a new Recordset object. If the command is not intended to return results (for example, an SQL UPDATE query) the provider returns Nothing as long as the option adExecuteNoRecords is specified; otherwise Execute returns a closed Recordset.

[u]The returned Recordset object is always a read-only, forward-only cursor. If you need a Recordset object with more functionality, first create a Recordset object with the desired property settings, then use the Recordset object's Open method to execute the query and return the desired cursor type.</u>

The contents of the CommandText argument are specific to the provider and can be standard SQL syntax or any special command format that the provider supports.

An ExecuteComplete event will be issued when this operation concludes.

Note URLs using the http scheme will automatically invoke the Microsoft OLE DB Provider for Internet Publishing. For more information, see Absolute and Relative URLs.

I came up with a work around using some logic instead of using objRS.MovePrevious command.

I hope this helps.

 
Old April 7th, 2004, 01:08 PM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hcweb
Default

Thanks for the response. For some reason, I am drawn to using Command. Don't know why....





Similar Threads
Thread Thread Starter Forum Replies Last Post
Command text was not set for the command object Sheraz Khan Classic ASP Databases 2 May 29th, 2007 12:57 AM
Change Cursor when over a cell gavins_satori Excel VBA 3 April 20th, 2006 03:47 AM
Command text was not set for the command object. deepa12 BOOK: Beginning ASP 3.0 5 November 2nd, 2004 05:37 PM
Recommended cursor type mario_sanchezh Pro VB Databases 1 November 26th, 2003 12:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.