Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    Errore di impaginazione asp con Oracle

    Ciao a tutti,

    ho un problema con l'impaginazione di una select fatta su una vista di oracle!
    Questo è il codice:

    codice:
    <%
    iPageSize = 10 'NUMERO RECORD PER PAGINA
    			
    			PR = trim(Request( "PR" ))
    			PN = trim(Request( "PN" ))
    			USERNAME = trim(Request( "USERNAME" ))
    			PSW = trim(Request( "PSW" ))
    			
    			
    			If Request.QueryString("page") = "" Then
    				iPageCurrent = 1
    			Else
    				iPageCurrent = CInt(Request.QueryString("page"))
    			End If
    
                strSQL = "SELECT web_prod.product_ID, web_prod.product_name, web_prod.product_Version, web_prod.product_Publisher, web_prod.product_Language, web_prod.product_Media, web_prod.product_OS, web_prod.product_PPrice from web_prod where Upper(web_prod.product_Publisher) like Upper('%" & PR & "%') and Upper(web_prod.Product_name) LIKE Upper('%" & PN & "%') ORDER BY web_prod.Product_NAME"
     
    			Set objRS = Server.CreateObject("ADODB.Recordset")
    			objRS.PageSize = iPageSize
    			objRS.CacheSize = iPageSize
    			objRS.Open strSQL, Cnn, adOpenStatic, adLockReadOnly, adCmdText 
    			
    			
    			reccount = objRS.recordcount
    			iPageCount = objRS.PageCount 
    
    			If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
    			If iPageCurrent < 1 Then iPageCurrent = 1
    
    			If iPageCount = 0 Then
    				Response.Write "
    
    <table><td><font face='verdana' size='2' color='#000000'>Non sono stati trovati i Prodotti.</td></table></p>"
    			Else
    				objRS.AbsolutePage = iPageCurrent
    				iRecordsShown = 0
    				%>
    				<table  align=center cellpadding="0" cellspacing="0" border="0" width="100">
    					<tr>
    						<td bgcolor="#cccccc">
    							<div align="center">
    							<table cellpadding="0" cellspacing="0" border="0" width="450">
    								<tr bgcolor="#FFFFFF" height="22">
    									<td WIDTH="2%"></td>
    									<td WIDTH="48%"></td>
    									<td WIDTH="8%" align="center"></td>
    									<td WIDTH="10%" align="center"></td>
    									<td WIDTH="12%" align="center"></td>
    									<td WIDTH="10%"  align="center"></td>
    									<td WIDTH="10%"  align="center"></td>
    								</tr>
    								<%
    								'SI VISUALIZZA IL CONTENUTO DELLA STRINGA SQL
    								'ALL'INTERNO DELLA TABELLA PRIMA DEFINITA
    								cont=1
    								Do While iRecordsShown < iPageSize And Not objRS.EOF
    									Dim Rig, bg
    									Rig = Rig + 1
    									If Rig Mod 2 = 0 then
    										bg = "#ffffff"
    									Else
    										bg = "#99ccff"	
    									End if	
    									Response.Write "<tr bgcolor = " & bg & "><td><font color='#000000' face='Verdana' size='1'>" & (iPageSize*iPageCurrent)-iPageSize+Cont & "</font></td>"
    									Response.Write "<td align='left'><font color='#000000' face='Verdana' size='1' class='linkpannello'>" & objRS("Product_Name") & "</font></td>"
    									Response.Write "<td align='center'><font color='#000000' face='Verdana' size='1'>" & objRS("Product_Version") & "</font></td>"
    									Response.Write "<td align='center'><font color='#000000' face='Verdana' size='1'>" & objRS("Product_Language") & "</font></td>"
    									Response.Write "<td align='center'><font color='#000000' face='Verdana' size='1'>" & objRS("Product_Media") & "</font></td>"
    									Response.Write "<td align='center'><font color='#000000' face='Verdana' size='1'>" & objRS("Product_OS") & "</font></td>"
    									Response.Write "<td align='center'><form method='post' name='Dettagli' action='Ricerca_FaseB2.asp'><input type='hidden' name='username' value="&username&" /><input type='hidden' name='psw' value="&psw&"><input type='hidden' name='pid' value="&objRS("Product_ID")&"><input type='hidden' name='pn' value="&objRS("Product_Name")&" ><input type='hidden' name='pr' value="&objRS("product_Publisher")&"><input type='image' src='Images/VaiAnimato.gif' name='Submit' value='vai' alt='vai' /></td></form>"
    									Cont = Cont + 1
    									'POSIZIONAMENTO ALLA RIGA SUCCESSIVA DEL DB
    									iRecordsShown = iRecordsShown + 1
    									objRS.MoveNext
    								Loop
    								'PULIZIA DEGLI OGGETTI ADO
    								objRS.Close
    								Set objRS = Nothing
    								%>
    						  </table>
    							</div>
    						</td>
    					</tr>
    				</table>
    			<%End if%>
    			
    
    
    			<%If ipagecount <> 1 Then%>
    		  <center>
    				<table width="420">
    					<tr valign="middle">
    						<td width="94%" align="center" valign="middle"><font face="verdana" size="1" color="#000000">
    							[
    							<%if iPageCurrent-2 > 0 and iPageCurrent > 2 then%>
    								&pn=<%=Request("pn")%>&username=<%=Request("username")%>&psw=<%=Request("psw")%>">[img]images/first.gif[/img]
    							<%end if%>
    							<%if iPageCurrent > 1 then%>
    								&pn=<%=Request("pn")%>&username=<%=Request("username")%>&psw=<%=Request("psw")%>">[img]images/pre.gif[/img]
    							<%end if%>
    							<%if iPageCount > 2 then
    								if iPageCurrent-2 < 1 then da_pag = 1 else da_pag = iPageCurrent-2
    								if iPageCurrent+2 > iPageCount then fino_a_pag = iPageCount else fino_a_pag = iPageCurrent+2
    							else
    								da_pag = 1
    								fino_a_pag = iPageCount
    							end if%>
    							<%for i = da_pag to fino_a_pag%>
    								<%if i = iPageCurrent then%>
    									<font color="red"><%=i%></font>
    								<%else%>	
    									&pn=<%=Request("pn")%>&username=<%=Request("username")%>&psw=<%=Request("psw")%>"><%=i%>
    								<%end if%>	
    							<%next%>
    							<%if iPageCurrent > 0 and iPageCurrent < iPageCount then%>
    								&pn=<%=Request("pn")%>&username=<%=Request("username")%>&psw=<%=Request("psw")%>">[img]images/next.gif[/img]
    							<%end if%>	
    							<%if iPageCurrent+1 < iPageCount then%>
    								&pn=<%=Request("pn")%>&username=<%=Request("username")%>&psw=<%=Request("psw")%>">[img]images/last.gif[/img]
    							<%end if%>	
    							]
    						</font></td>
    					</tr>
    					<tr>
    						<td colspan="2" align="center"><font face="verdana" size="1" color="#000000">
    							<center>
    							Pagina
    								<font color="#FF0000"><%=iPageCurrent%></font>
    								di
    								<font color="#FF0000"><%=iPageCount%></font>
    							</center>
    						</font></td>
    					</tr>
    				</table>
    		  </center>
    			<%end if%>
    			<%
    			Cnn.Close
    			Set Cnn = Nothing
    			%>
    il problema è che mi da errore, l'errore che mi presenta è:
    error '80004005'
    sulla riga:
    codice:
    reccount = objRS.recordcount
    niente altro...

    sono gia disabilitate le flag sugli errori brevi

    come può essere?
    usando un db access non da nessun errore..

    mi potete dare una mano?
    :metallica
    Che cosa vuoi che ti dica???
    Senti che bel rumore...

  2. #2
    Può essere il mio tipo di connessione?

    codice:
    Set Cnn=Server.CreateObject("ADODB.Connection") 
    cnn.CursorLocation=3 
    cnn.ConnectionSTring="DSN=Ciccia;uid=Ciuccia; pwd=Piccia" 
    cnn.open
    che ne dite??
    :metallica
    Che cosa vuoi che ti dica???
    Senti che bel rumore...

  3. #3
    Nessun Suggerimento
    :metallica
    Che cosa vuoi che ti dica???
    Senti che bel rumore...

  4. #4
    Ho provato cosi:

    codice:
    <%
    iPageSize = 10 'NUMERO RECORD PER PAGINA
    PR = trim(Request( "PR" ))
    PN = trim(Request( "PN" ))
    			
    If Request.QueryString("page") = "" Then
    iPageCurrent = 1
    
    Else
    iPageCurrent = CInt(Request.QueryString("page"))
    
    End If
    
    ' Count SQL
    SQLSX = "Select Count(*) as MyPorcata From web_prod where Upper(web_prod.product_Publisher) like Upper('%" & PR & "%') and Upper(web_prod.Product_name) LIKE Upper('%" & PN & "%') ORDER BY web_prod.Product_NAME"
    set RSSQLSX = cnn.execute(SQLSX)
    			
    TRecord = RSSQLSX("MyPorcata")
    			
    strSQL = "SELECT rownum, web_prod.product_ID, web_prod.product_name, web_prod.product_Version, web_prod.product_Publisher, web_prod.product_Language, web_prod.product_Media, web_prod.product_OS, web_prod.product_PPrice from web_prod where Upper(web_prod.product_Publisher) like Upper('%" & PR & "%') and Upper(web_prod.Product_name) LIKE Upper('%" & PN & "%') ORDER BY web_prod.Product_NAME"
    
    Set objRS = Server.CreateObject("ADODB.Recordset")
    objRS.PageSize = iPageSize
    objRS.CacheSize = iPageSize
    objRS.Open strSQL, Cnn, adOpenStatic, adLockReadOnly, adCmdText 
    			
    			
    reccount = TRecord
    AiPageCount = reccount / iPageSize
    BipageCount = int(AiPageCount)
    CipageCount = AiPageCount - BiPageCount
    If CipageCount > 0 then
    ipageCount = BipageCount + 1
    else 
    ipageCount = BipageCount
    end if
    			
    If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
    If iPageCurrent < 1 Then iPageCurrent = 1
    
    If iPageCount = 0 Then
    Response.Write "
    
    <table><td><font face='verdana' size='2' color='#000000'>Non sono stati trovati i Prodotti.</td></table></p>"
    Response.Write "RecCount " & reccount & " - IpageCount" & iPageCount & ""
    Else
    objRS.AbsolutePage = iPageCurrent
    iRecordsShown = 0
    %>
    <table  align=center cellpadding="0" cellspacing="0" border="0" width="100">
     <tr>
    	<td bgcolor="#cccccc">
    	<div align="center">
    	 <table cellpadding="0" cellspacing="0" border="0" width="450">
    		<tr bgcolor="#FFFFFF" height="22">
    			<td WIDTH="2%"></td>
    			<td WIDTH="58%"></td>
    			<td WIDTH="5%" align="center"></td>
    			<td WIDTH="10%" align="center"></td>
    			<td WIDTH="10%" align="center"></td>
    			<td WIDTH="14%"  align="center"></td>
    		</tr>
    <%
    'SI VISUALIZZA IL CONTENUTO DELLA STRINGA SQL
    'ALL'INTERNO DELLA TABELLA PRIMA DEFINITA
    cont=1
    Do While iRecordsShown < iPageSize And Not objRS.EOF
    Dim Rig, bg
    Rig = Rig + 1
    If Rig Mod 2 = 0 then
    	bg = "#ffffff"
    Else
    	bg = "#99ccff"	
    End if	
    Response.Write "<tr bgcolor = " & bg & "><td><font color='#000000' face='Verdana' size='1'>" & (iPageSize*iPageCurrent)-iPageSize+Cont & "</font></td>"
    Response.Write "<td align='left'><font color='#000000' face='Verdana' size='1' class='linkpannello'><a href=Ricerca_PFasec.asp?PID=" & objRS("Product_ID") & "&PR=" & objRS("product_Publisher") &"&Pn=" & objRS("Product_Name") &" class=linkpannello> " & objRS("Product_NAME") & "</a></font></td>"
    Response.Write "<td align='center'><font color='#000000' face='Verdana' size='1'>" & objRS("Product_Version") & "</font></td>"
    Response.Write "<td align='center'><font color='#000000' face='Verdana' size='1'>" & objRS("Product_Language") & "</font></td>"
    Response.Write "<td align='center'><font color='#000000' face='Verdana' size='1'>" & objRS("Product_Media") & "</font></td>"
    Response.Write "<td align='center'><font color='#000000' face='Verdana' size='1'>" & objRS("Product_OS") & "</font></td>"
    Cont = Cont + 1
    'POSIZIONAMENTO ALLA RIGA SUCCESSIVA DEL DB
    iRecordsShown = iRecordsShown + 1
    objRS.MoveNext
    Loop
    'PULIZIA DEGLI OGGETTI ADO
    objRS.Close
    Set objRS = Nothing
    %>
    </table>
    </div>
    </td>
    </tr>
    </table>
    <%End if%>
    
    
    
    <%If ipagecount <> 1 Then%>
    <center>
    <table width="420">
    <tr valign="middle">
    <td width="94%" align="center" valign="middle"><font face="verdana" size="1" color="#000000">
    [
    <%if iPageCurrent-2 > 0 and iPageCurrent > 2 then%>
    &pn=<%=Request("pn")%>">[img]images/first.gif[/img]
    <%end if%>
    <%if iPageCurrent > 1 then%>
    &pn=<%=Request("pn")%>">[img]images/pre.gif[/img]
    <%end if%>
    <%if iPageCount > 2 then
    if iPageCurrent-2 < 1 then da_pag = 1 else da_pag = iPageCurrent-2
    if iPageCurrent+2 > iPageCount then fino_a_pag = iPageCount else fino_a_pag = iPageCurrent+2
    else
    da_pag = 1
    fino_a_pag = iPageCount
    end if%>
    <%for i = da_pag to fino_a_pag%>
    <%if i = iPageCurrent then%>
    <font color="red"><%=i%></font>
    <%else%>	
    &pn=<%=Request("pn")%>"><%=i%>
    <%end if%>	
    <%next%>
    <%if iPageCurrent > 0 and iPageCurrent < iPageCount then%>
    &pn=<%=Request("pn")%>">[img]images/next.gif[/img]
    <%end if%>	
    <%if iPageCurrent+1 < iPageCount then%>
    &pn=<%=Request("pn")%>">[img]images/last.gif[/img]
    <%end if%>	
    ]
    </font></td>
    </tr>
    <tr>
    <td colspan="2" align="center"><font face="verdana" size="1" color="#000000">
    <center>
    Pagina
    <font color="#FF0000"><%=iPageCurrent%></font>
    di
    <font color="#FF0000"><%=iPageCount%></font>
    </center>
    </font></td>
    </tr>
    </table>
    </center>
    <%end if%>
    <%
    Cnn.Close
    Set Cnn = Nothing
    %>
    Cosi ho raggirato il recordCount e il pagecount ma non so come raggirare l'absolutepage..

    avete qualche idea?
    :metallica
    Che cosa vuoi che ti dica???
    Senti che bel rumore...

  5. #5
    visto che con oracle ne hai la possibilità, limita l'intervallo dei record estratti direttamente con la query anziché utilizzare le proprietà dei recordset.
    guarda se questa funzione può esserti d'aiuto:
    codice:
    	private function oracleQuery(query, firstRec, lastRec)
    
    		query = TRim(query & "")
    
    		oracleQuery = "SELECT * FROM ( " & _
    						"SELECT a.*, ROWNUM rnum " & _
    						"FROM ( " & query & " ) a " & _
    						"WHERE ROWNUM <= " & lastRec & " ) " & _
    						"WHERE rnum >= " & firstRec
    
    	end function
    ti tira fuori i record della query che passi in input, compresi nell'intervallo [firstRec, lastRec].
    il totale dei record puoi ottenerlo con una semplice select count, tralasciando il recordcount.

    xxx

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.