0

LIMIT "&PageStart&" , "&PageEnd&"以下のクエリを削除すると、正常に動作します。データベースからすべてのデータを取得します。LIMITただし、これら 2 つのパラメーターでは機能しません。私は何を間違っていますか?

Dim Conn,strSQL,objRec
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "Driver={SQL Server}; Server=Localhost; Database=book-it-fifa;"
strSQL = "select distinct buchung_id, von, bis, abteilung, veranstalter, THEMA, THEMA_ENABLED " & _
    "  from RESERVIERUNGRAUM r  " & _
    "      ,BUCHUNG b  " & _
    " where r.BUCHUNG_ID = b.ID " & _
    "   and von >= convert(date, getdate(), 4) " & _
    "   and von < convert(date, dateadd(day,1, GETDATE()), 4) " & _
    "   and BIS >= getdate() " & _
    "   and STORNO is null  " 
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open strSQL, Conn, 1,3

If objRec.EOF Then
    Response.write (" Not found record.")   
Else

'**** Paging/Pagination Calculator ***'
Dim PageLen,PageNo,TotalRecord,TotalPage,intID
Dim PageStart,PageEnd
PageLen = 2 
PageNo = Request.QueryString("Page")
if PageNo = "" Then PageNo = 1
TotalRecord = UBound(objRec.GetRows,2)+1
PageStart = ((PageLen*PageNo)-PageLen)
PageEnd = PageLen
If TotalRecord <= PageLen Then
    TotalPage =1
ElseIf (TotalRecord Mod PageLen = 0) Then
    TotalPage =(TotalRecord/PageLen)
Else
    TotalPage =(TotalRecord/PageLen)+1
    TotalPage = Cint(TotalPage)
End If

'*** Close Object and Open New RecordSet ***'
objRec.Close()
strSQL = strSQL & "ORDER BY von, bis ASC LIMIT "&PageStart&" , "&PageEnd&" "
objRec.Open strSQL, Conn, 1,3
4

1 に答える 1

2

SQL Server は LIMIT をサポートしていません。詳細については、こちらをご覧ください。

http://channel9.msdn.com/Forums/Coffeehouse/102407-SQL-Server-and-LIMIT-clauses-on-SELECT-statements

于 2012-11-28T23:21:57.617 に答える