Solved

Using ASP and Sql Server Storedprocedure. not abel to MoveFirst in Recordset.

Posted on 2004-10-28
648 Views
Last Modified: 2012-06-27
     
Hi Members,

I am using Sql Server 2000.
i am not abel to movelast and movefirst in the Recordset.

The Stroedprocedure.
CREATE PROCEDURE [veenaimvsql].[AllFlashCards] AS
select ecid,smallcard,Hits from ecards where flash='True' order by ecid desc
GO


      Set objCmdECards=Server.CreateObject("adodb.command")
      objCmdECards.ActiveConnection = stringConn
      objCmdECards.CommandText = "FlashCards"
      objCmdECards.CommandType = adCmdStoredProc

      ObjRsFlashCards.Open objCmdECards.Execute
      Set objCmdECards = Nothing

If i give ObjRsFlashCards.Movefirst

Operation was canceled. - is the Error result in that line.

i am not abel to get the recordcount also if i use like this.
Recordcount Returns -1.

how can i do movefirst and get the Recordcount value.

Thank you.
0
Question by:nthilak
    2 Comments
     
    LVL 4

    Expert Comment

    by:rlibrandi
    You need to use client-side cursor to get recordcount.  Also, remember, movefirst, movenext, etc are RECORDSET operations.

    Try this

    Set rsECards = Server.CreateObject("ADODB.RecordSet")
    rsEcards.CursorLocation = adUseClient
    rsECards.Open "FlashCards", stringConn, 3,3
    0
     
    LVL 7

    Accepted Solution

    by:
    Hi,

    probably you should some articles about CursorLocation and CursorType (members of a recordset object)
    Default the CursorType of a recordset is adOpenForwardOnly. Then you'll understand that moving to the first record is impossible. Also a RecordCount is not possible with this cursortype.

    you're code may look like:
    Set objCmdECards=Server.CreateObject("adodb.command")
         objCmdECards.ActiveConnection = stringConn
         objCmdECards.CommandText = "FlashCards"
         objCmdECards.CommandType = adCmdStoredProc

         Set ObjRsFlashCards = Server.CreateObject("adodb.Recordset")
         ObjRsFlashCards.CursorLocation = adUseClient
         ObjRsFlashCards.CursorType  = adOpenStatic
         ObjRsFlashCards.Open objCmdECards.Execute
         Set objCmdECards = Nothing

    ObjRsFlashCards.Movefirst
    In this example the adOpenStatic lets you move through the recordset forward and backwards...

    To understand more about these cursor-things you should read http://www.adopenstatic.com/faq/jetcursortypes.asp

    Hope we have helped
    kGenius
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Learn The Basics of Ethical Hacking & Pen Testing

    Computer and network security is one of the fastest growing and most essential industries in technology, meaning companies will pay big bucks for ethical hackers. This is the perfect course to leap into this lucrative career, learning how to use ethical hacking to reveal ...

    Are you into PHP development and curious how you can make your life easier when publishing your website? Do you sometimes worry you might forget to remove debug lines? Or you spend unnecessary time to double check you haven't accidentally uploaded '…
    Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
    Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

    934 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now