%
Dim rsPdv
Dim rsPdv_numRows
Set rsPdv = Server.CreateObject("ADODB.Recordset")
rsPdv.ActiveConnection = MM_webcontem1g_STRING
rsPdv.Source = "SELECT distinct(codigo) as totalPdv FROM dbo.webpdv WHERE status = 'ATIVO'"
rsPdv.CursorType = 0
rsPdv.CursorLocation = 2
rsPdv.LockType = 1
rsPdv.Open()
rsPdv_numRows = 0
%>
<%
Dim rsPdd
Dim rsPdd_numRows
Set rsPdd = Server.CreateObject("ADODB.Recordset")
rsPdd.ActiveConnection = MM_webcontem1g_STRING
rsPdd.Source = "SELECT count(codigo) as totalPdd FROM webpdd WHERE status = 'ATIVO'"
rsPdd.CursorType = 0
rsPdd.CursorLocation = 2
rsPdd.LockType = 1
rsPdd.Open()
rsPdd_numRows = 0
%>
<%
' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables
Dim rsPdv_total
Dim rsPdv_first
Dim rsPdv_last
' set the record count
rsPdv_total = rsPdv.RecordCount
' set the number of rows displayed on this page
If (rsPdv_numRows < 0) Then
rsPdv_numRows = rsPdv_total
Elseif (rsPdv_numRows = 0) Then
rsPdv_numRows = 1
End If
' set the first and last displayed record
rsPdv_first = 1
rsPdv_last = rsPdv_first + rsPdv_numRows - 1
' if we have the correct record count, check the other stats
If (rsPdv_total <> -1) Then
If (rsPdv_first > rsPdv_total) Then
rsPdv_first = rsPdv_total
End If
If (rsPdv_last > rsPdv_total) Then
rsPdv_last = rsPdv_total
End If
If (rsPdv_numRows > rsPdv_total) Then
rsPdv_numRows = rsPdv_total
End If
End If
%>
<%
' *** Recordset Stats: if we don't know the record count, manually count them
If (rsPdv_total = -1) Then
' count the total records by iterating through the recordset
rsPdv_total=0
While (Not rsPdv.EOF)
rsPdv_total = rsPdv_total + 1
rsPdv.MoveNext
Wend
' reset the cursor to the beginning
If (rsPdv.CursorType > 0) Then
rsPdv.MoveFirst
Else
rsPdv.Requery
End If
' set the number of rows displayed on this page
If (rsPdv_numRows < 0 Or rsPdv_numRows > rsPdv_total) Then
rsPdv_numRows = rsPdv_total
End If
' set the first and last displayed record
rsPdv_first = 1
rsPdv_last = rsPdv_first + rsPdv_numRows - 1
If (rsPdv_first > rsPdv_total) Then
rsPdv_first = rsPdv_total
End If
If (rsPdv_last > rsPdv_total) Then
rsPdv_last = rsPdv_total
End If
End If
%>