RS.MoveLast doesn't work; even with correct c

Results 1 to 3 of 3

Thread: RS.MoveLast doesn't work; even with correct c

  1. #1
    Join Date
    Dec 1969

    Default RS.MoveLast doesn't work; even with correct c

    I am trying to use the ADO method MoveLast. I can get it to work, but even though my Table has an column named &#039;ID&#039; populated with the numbers 1-45 it always returns 39. When I run a query on the table the number are not ordered. This is the code I am using:<BR><BR>-----------CODE----------------------<BR>RS.Open "SomeTable", Conn,1,3<BR>rs.movelast<BR><BR>Response.Write(RS(" ID"))<BR>------------------------------------<BR><BR>I also tried it this way:<BR><BR><BR>-----------CODE----------------------<BR>RS.Open "Select ID from SoemTable order by ID", Conn, adOpenStatic, adLockOptimistic<BR><BR>rs.movelast<BR><BR>NewID = RS("ID")<BR>Response.Write(NewID)<BR>-------------------------------<BR><BR>But then I get the error: Rowset does not support fetching backward. The table does not have an index (I think). Any ideas??<BR><BR><BR>Thanks!!! <BR><BR>-- Jennifer<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: RS.MoveLast doesn't work; even with corre

    What are you trying to do? To get the highest ID use <BR><BR>set rs = conn.execute("select max(id) from sometable")<BR><BR>If this is some attempt to get the newly generated value for an auto_increment column, it is not the proper way.

  3. #3
    Join Date
    Dec 1969

    Default Lars is absolutely right...

    ...but among the things you didn&#039;t tell us: What kind of Database? Do you, indeed, have "" #include&#039;d in that page?<BR><BR>[I&#039;m curious why you used 1,3 for the first form but the named constants for the second.]<BR><BR>And you don&#039;t seem to be doing any "fetching backwards", so are you showing all the code?<BR><BR>Anyway, the *right* way to get a new ID is shown in the ASPFAQs, category "Databases, General" I think. I revised it in April.<BR><BR>Why doesn&#039;t the table have an index? (Not that it should matter--except for performance of the 2nd version.)<BR><BR>

Posting Permissions

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