后端是SQLSERVER,如何选取最后一条记录?

解决方案 »

  1.   

    rs.open "select * from 表",cn,3,3
    if not rs.eof then rs.movenext
    此时的记录指针为最后一条记录
      

  2.   

    把你的记录倒序排一下就可以啦
    rs.open "select * from 表 order by fid desc",cn......
    取第一条记录就是你的最后一条记录了。
      

  3.   

    if rs.state=adstateopen then rs.close
    rs.open "select * from tablename",adopenkeyset,adlockreadonly
    if rs.recordcount>0 then
        rs.movelast
    end if'或
    rs.open "select max(字段) from tablename",adopenkeyset,adlockreadonly
      

  4.   

    strSql="SELECT TOP 1 FROM YourTable ORDER BY MainID DESC"
      

  5.   

    Dim rstLoad As ADODB.RecordSet
    Dim strSql As String
       strSql="SELECT * FROM TableName"
       Set rstLoad=New ADODB.RecordSet
       rstLoad.Open strSql,gConn,adopenkeyset,adlockreadonly
       If Not rstLoad.EOF Then
           rstLoad.MoveLast
           'Do what you want...
       End If