MoveLast Problem : ADO


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: MoveLast Problem : ADO

  1. #1
    Syrus Guest

    MoveLast Problem : ADO


    Hi ALL!!!
    I want to fetch a record using SQL query through ADO and AFTER that i want
    to know that record has been fetched or not.But i m getting an error as
    below:

    Error: it gives me the error that rowset doesnt support backward searching

    ErrNo:2147217884

    Here is the code im using :
    Assume : Conn as a valid connection

    Public Sub Check()
    Dim Rs as ADODB.RecordSet
    Set Rs = New ADODB.Recordset
    Rs.CursorType = adOpenDynamic
    Rs.LockType = adLockOptimistic


    Set Rs = Conn.Execute("Select * from MyTable Where my_code='myValue'")

    Rs2.MoveLast <----------------Here is the Problem
    Rs.MoveFirst

    If Rs.RecordCount >= 1 Then
    MsgBox "This Rec Already exists"
    End If

    End Sub

    Any ideas ??
    Any help will be appreciated
    Syrus



  2. #2
    Mort Guest

    Re: MoveLast Problem : ADO

    Hi Syrus,

    Try checking Rs2.Eof and Rs2.Bof before proceeding to the MoveLast.

    Ummm on second looks... is the '2' a typo?

    Mort

    "Syrus" <sanjivus@aol.com> wrote in message news:39a539c0$1@news.devx.com...
    >
    > Hi ALL!!!
    > I want to fetch a record using SQL query through ADO and AFTER that i want
    > to know that record has been fetched or not.But i m getting an error as
    > below:
    >
    > Error: it gives me the error that rowset doesnt support backward searching
    >
    > ErrNo:2147217884
    >
    > Here is the code im using :
    > Assume : Conn as a valid connection
    >
    > Public Sub Check()
    > Dim Rs as ADODB.RecordSet
    > Set Rs = New ADODB.Recordset
    > Rs.CursorType = adOpenDynamic
    > Rs.LockType = adLockOptimistic
    >
    >
    > Set Rs = Conn.Execute("Select * from MyTable Where my_code='myValue'")
    >
    > Rs2.MoveLast <----------------Here is the Problem
    > Rs.MoveFirst
    >
    > If Rs.RecordCount >= 1 Then
    > MsgBox "This Rec Already exists"
    > End If
    >
    > End Sub
    >
    > Any ideas ??
    > Any help will be appreciated
    > Syrus
    >
    >




  3. #3
    Tom Wilson Guest

    Re: MoveLast Problem : ADO


    If you want to check for the existence of a record, why not just use a Select
    Count(*)?

    >Public Sub Check()


    > Dim Rs as ADODB.Recordset
    > Set Rs = New ADODB.Recordset
    > Rs.CursorType = adOpenDynamic
    > Rs.LockType = adLockOptimistic
    >
    >

    Set Rs = Conn.Execute("Select Count(*) from MyTable Where my_code='myValue'")

    If Rs.Fields(0) >= 1 Then
    MsgBox "This Rec Already exists"
    End If
    >
    >End Sub



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center