'page = CInt(Request("page"))
'rp = CInt(Request("rows"))
'sortname = Request("sidx")
'sortorder = Request("sord")
page = 1
rp = 10
sortname = "depto_ide"
sortorder = "asc"
if sortname = "" then
sortname = "depto_ide"
end if
if sortorder = "" then
sortorder = "asc"
end if
order = "Order By "&sortname&" "&sortorder&""
if page = "" then
page = 2
end if
if rp = 0 then
rp = 4
end if
strStart = (rp*page) -rp
strStart = (page -1) * rp
If (strStart < 0) Then
strStart = 0
End If
limit ="Limit "&strStart&","&cdbl(rp)&""
'strSearchOn = Request("_search")
'If (strSearchOn = "true") Then
'strField = Request("searchField")
' If (strField = "depto_desc") Then
' strFieldData = Request("searchString")
' strSearchOper = Request("searchOper")
' 'construct where
' strWhere = " Where " & strField
'
' Select Case strSearchOper
' Case "bw" : 'Begin With
' strFieldData = strFieldData & "%"
' strWhere = strWhere & " LIKE '" & strFieldData & "'"
' Case "eq" : 'Equal
' If(IsNumeric(strFieldData)) Then
' strWhere = strWhere & " = " & strFieldData
' Else
' strWhere = strWhere & " = '" & strFieldData & "'"
' End If
' Case "ne": 'Not Equal
' If(IsNumeric(strFieldData)) Then
' strWhere = strWhere & " <> " & strFieldData
' Else
' strWhere = strWhere & " <> '"& strFieldData &"'"
' End If
' Case "lt": 'Less Than
' If(IsNumeric(strFieldData)) Then
' strWhere = strWhere & " < " & strFieldData
' Else
' strWhere = strWhere & " < '"& strFieldData &"'"
' End If
' Case "le": 'Less Or Equal
' If(IsNumeric(strFieldData)) Then
' strWhere = strWhere & " <= " & strFieldData
' Else
' strWhere = strWhere & " <= '"& strFieldData &"'"
' End If
' Case "gt": 'Greater Than
' If(IsNumeric(strFieldData)) Then
' strWhere = strWhere & " > " & strFieldData
' Else
' strWhere = strWhere & " > '"& strFieldData &"'"
' End If
' Case "ge": 'Greater Or Equal
' If(IsNumeric(strFieldData)) Then
' strWhere = strWhere & " >= " & strFieldData
' Else
' strWhere = strWhere & " >= '"& strFieldData &"'"
' End If
' Case "ew" : 'End With
' strWhere = strWhere & " LIKE '%" & strFieldData & "'"
' Case "cn" : 'Contains
' strWhere = strWhere & " LIKE '%" & strFieldData & "%'"
' End Select
'
' End if
'End If
Set Conn_sql = Server.CreateObject("ADODB.Connection")
Conn_sql.Open ConString
set rs_info = server.CreateObject("ADODB.Recordset")
sql = "Select * From departamentos "&strWhere&" "&order&" "&limit&" "
Set rs = Conn_SQL.Execute(sql)
'$total = countRec("iso","country $where");
sql_total = "Select count(*) as total From departamentos "&strWhere
Set rs_total = Conn_SQL.Execute(sql_total)
if ( cdbl(rs_total("total")) mod cdbl(rp) ) > 0 then
total_paginas = cint(( cdbl(rs_total("total")) / cdbl(rp) )) '+1
else
total_paginas = ( cdbl(rs_total("total")) / cdbl(rp) )
end if
Response.Write ("<?xml version='1.0' encoding='iso-8859-1'?>")
Response.Write ("<rows>")
Response.Write ("<page>"&cdbl(Page)&"</page>")
Response.Write ("<total>"&cdbl(total_paginas)&"</total>")
Response.Write ("<records>"&cdbl(rs_total("total"))&"</records>")
rs.MoveFirst
Do While Not rs.Eof
Response.contenttype = "text/xml"
Response.Write "<row id='"&rs("depto_ide")&"'>"
Response.Write "<cell>"&rs("depto_ide")&"</cell>"
Response.Write "<cell><![CDATA["&rs("depto_desc")&"]]></cell>"
Response.Write "<cell><![CDATA["&rs("depto_imagen")&"]]></cell>"
If rs("depto_activo")=1 then
Response.Write "<cell>ACT</cell>"
else
Response.Write "<cell></cell>"
end if
Response.Write "<cell><![CDATA["&rs("depto_visitas")&"]]></cell>"
Response.Write "<cell><![CDATA["&rs("depto_descripcion")&"]]></cell>"
Response.Write "</row>"
rs.MoveNext
Loop
Response.Write "</rows>"
rs.Close
Set Conn = Nothing