Results 1 to 2 of 2

Thread: ADO Error

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    UK
    Posts
    147

    Question ADO Error

    When I run this script I get the error: Rowset does not support fetching backward.

    This error occurs when I try to use the Rst.MoveLast command but I was under the impression that I could do this if I had opened the record set as "Rst.CursorType = adOpenDynamic" obviously I am doing something wrong here can someone point me in the right direction please.


    VB Code:
    1. Dim CN As New ADODB.Connection
    2. Dim Cmd As New ADODB.Command
    3. Dim Rst As New ADODB.Recordset
    4. Dim DeviceCount As Integer
    5. Dim Count As Integer
    6.  
    7. 'Open DB Connection
    8. CN.Open DBPath
    9.  
    10. Set Rst = New ADODB.Recordset
    11. Rst.CursorType = adOpenDynamic
    12. Rst.Supports (adMovePrevious)
    13.  
    14.  
    15. 'Prepare the user-defined function statement and execute the command.
    16. Cmd.ActiveConnection = CN
    17. Cmd.CommandText = "SELECT DeviceName, DeviceType, CMACNum, Address, PLCID, NumEvents, StartRead, StopRead FROM SOEWFC_Definitions;"
    18. Set Rst = Cmd.Execute
    19.  
    20.    
    21. 'Check to see if there are any records in the table
    22. If Rst.EOF = False Then
    23.     'get number of rows in Backups table
    24.     Rst.MoveLast
    25.     DeviceCount = Rst.RecordCount
    26.     Rst.MoveFirst
    27. End If

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: ADO Error

    Originally posted by mik706

    VB Code:
    1. Dim CN As New ADODB.Connection
    2. Dim Cmd As New ADODB.Command
    3. Dim Rst As New ADODB.Recordset
    4. Dim DeviceCount As Integer
    5. Dim Count As Integer
    6.  
    7. 'Open DB Connection
    8. CN.Open DBPath
    9.  
    10. Set Rst = New ADODB.Recordset
    11. Rst.CursorType = adOpenDynamic
    12.  
    13. '---- what is this??? I couldn't find help on it - you don't need it!
    14. 'Rst.Supports (adMovePrevious)
    15.  
    16.  
    17. 'Prepare the user-defined function statement and execute the command.
    18. Cmd.ActiveConnection = CN
    19. Cmd.CommandText = "SELECT DeviceName, DeviceType, CMACNum, Address, PLCID, NumEvents, StartRead, StopRead FROM SOEWFC_Definitions;"
    20.  
    21. '---- why do ppl execute when its open ?
    22. '- can't remember the options flags ;)
    23. 'rst.open strSql,cn,option,option,adcmdtext
    24. Set Rst = Cmd.Execute
    25.  
    26. '---- being picky - but no checks to see whether the db opened? ;) or the recordset opened ;) rst.state=adstateopen    
    27. 'Check to see if there are any records in the table
    28. If Rst.EOF = False Then
    29.     'get number of rows in Backups table
    30.     Rst.MoveLast
    31.     DeviceCount = Rst.RecordCount
    32.     Rst.MoveFirst
    33. End If
    Sorry for the extra remarks - ignore if you feel so.
    Probably not working as you are executing cmd but not opening the recordset as dynamic (its being reset via the cmd).

    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width