Pagina 1 di 3 1 2 3 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 29

Discussione: Divisione per zero.

  1. #1
    Utente di HTML.it L'avatar di [trodat]
    Registrato dal
    Oct 2004
    Messaggi
    2,135

    Divisione per zero.

    Questo codice restitusce l'errore in oggetto sulla linea indicata, come mai?:

    codice:
    	iDBLoc = CInt(Request("iDBLoc"))
    	iTtlNumItems = CInt(Request("iTtlNumItems"))
    	
    	if (iTtlNumItems = 0) then
    		Set rsObj = Server.CreateObject("ADODB.Recordset")
    		sSqlTemp = "SELECT COUNT(*) FROM GestioneTbl"
    		rsObj.Open sSqlTemp, conn, 3, 3
    		If Not(rsObj.EOF) Then
    			iTtlNumItems = rsObj(0)
    		End If
    		rsObj.Close
    		Set rsObj = Nothing
    	end if
    
    	iTtlTemp = iTtlNumItems / iNumPerPage <----- riga errore-------<	
    
    	iDBLocTemp = iDBLoc / iNumPerPage		
    	If (sQuerystring <> "") Then
    		sURLBeg = "<a href = """ & sURL & "?" & sQuerystring & "&iTtlNumItems=" & iTtlNumItems & "&iDBLoc="
    	Else
    		sURLBeg = "<a href = """ & sURL & "?iTtlNumItems=" & iTtlNumItems & "&iDBLoc="
    	End If
    Lo Stato dà un posto. L’impresa privata dà un lavoro. – Indro Montanelli

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    iNumPerPage da dove arriva???

    Roby

  3. #3
    Utente di HTML.it L'avatar di [trodat]
    Registrato dal
    Oct 2004
    Messaggi
    2,135
    Originariamente inviato da Roby_72
    iNumPerPage da dove arriva???

    Roby
    E' un codice di paginazione che ho scaricato da un sito...

    codice:
    <%
    
    Sub PrintRecordsetNav( iNumPerPage, adodbConnection, adodbCommand, sTable, sURL, sQuerystring )
    	
    	Dim iTtlNumItems, iDBLoc, sSqlTemp, iTtlTemp
    	Dim iDBLocTemp, sURLBeg, iA, iB, x, iTemp, rsObj
    	
    	iDBLoc = CInt(Request("iDBLoc"))
    	iTtlNumItems = CInt(Request("iTtlNumItems"))
    	' Get ttl num of items from the database if it's not already in the QueryString
    	if (iTtlNumItems = 0) then
    		Set rsObj = Server.CreateObject("ADODB.Recordset")
    		sSqlTemp = "SELECT COUNT(*) FROM " & sTable
    		adodbCommand.CommandText = sSqlTemp
    		rsObj.Open adodbCommand
    		If Not(rsObj.EOF) Then
    			iTtlNumItems = rsObj(0)
    		End If
    		rsObj.Close
    		Set rsObj = Nothing
    	end if
    	iTtlTemp = iTtlNumItems \ iNumPerPage	' this is the number of numbers overall (use the "\" to return int)
    	iDBLocTemp = iDBLoc \ iNumPerPage		' this is which number we are currently on (use the "\" to return int)
    	If (sQuerystring <> "") Then
    		sURLBeg = "<a href = """ & sURL & "?" & sQuerystring & "&iTtlNumItems=" & iTtlNumItems & "&iDBLoc="
    	Else
    		sURLBeg = "<a href = """ & sURL & "?iTtlNumItems=" & iTtlNumItems & "&iDBLoc="
    	End If
    	
    	'***** BEGIN DISPLAY *****
    	' Print the "Previous"
    	if (iDBLoc <> 0) then
    		Response.Write sURLBeg & (iDBLoc - iNumPerPage) & """>Previous</a>  "
    	end if
    	' Print the <<
    	if (iDBLocTemp >= iNumPerPage) then
    		Response.Write sURLBeg & (( iDBLocTemp \ iNumPerPage ) * iNumPerPage ^ 2) - (iNumPerPage * 9) & """><<</a> "
    	end if
    	
    	' Print the numbers in between. Print them out in sets of 10.
    	iA = ( iDBLocTemp \ iNumPerPage ) * iNumPerPage
    	iB = ( iDBLocTemp \ iNumPerPage ) * iNumPerPage + iNumPerPage
    	for x = iA to iB
    		iTemp = (x * iNumPerPage)
    		if (iTemp < iTtlNumItems) then	' takes care of extra numbers after the overall final number
    			if (iDBLoc = iTemp) then
    				Response.Write " [" & x+1 & "]"
    			else
    				Response.Write " " & sURLBeg & (x * iNumPerPage) & """>" & x+1 & "</a>"
    			end if
    		else
    			exit for
    		end if
    	next
    	
    	' Print the >>
    	if (iTtlTemp > iDBLocTemp) then
    		if ((iDBLocTemp + iNumPerPage) <= iTtlTemp) then
    			Response.Write " " & sURLBeg & (( iDBLocTemp \ iNumPerPage ) * iNumPerPage + iNumPerPage ) * iNumPerPage & """>>></a> "
    		end if
    	end if
    	' Print the "Next"
    	if ((iDBLoc + iNumPerPage) < iTtlNumItems) then
    		Response.Write "  " & sURLBeg & (iDBLoc + iNumPerPage) & """>Next</a>"
    	end if
    	'***** END DISPLAY *****
    	
    End Sub
    
    %>
    Lo Stato dà un posto. L’impresa privata dà un lavoro. – Indro Montanelli

  4. #4
    Utente di HTML.it L'avatar di [trodat]
    Registrato dal
    Oct 2004
    Messaggi
    2,135
    In questo modo ho risolto!!! Grazie !!! :

    codice:
    iDBLoc = CInt(Request("iDBLoc"))
    	iTtlNumItems = CInt(Request("iTtlNumItems"))
    
    iNumPerPage = 6
    	
    	if (iTtlNumItems = 0) then
    		Set rsObj = Server.CreateObject("ADODB.Recordset")
    		sSqlTemp = "SELECT COUNT(*) FROM GestioneTbl"
    		rsObj.Open sSqlTemp, conn, 3, 3
    		
    		If Not(rsObj.EOF) Then
    			iTtlNumItems = rsObj(0)
            End If
    				
    		
    		rsObj.Close
    		Set rsObj = Nothing
    	end if
    Lo Stato dà un posto. L’impresa privata dà un lavoro. – Indro Montanelli

  5. #5
    Utente di HTML.it L'avatar di [trodat]
    Registrato dal
    Oct 2004
    Messaggi
    2,135
    Non vabene...

    Il codice infatti non dà errore estrae il numero di records ma non avanza nella paginazione...

    codice:
    <%
    	
    	iDBLoc = CInt(Request("iDBLoc"))
    	iTtlNumItems = CInt(Request("iTtlNumItems"))
    	
    	iNumPerPage = 3
    	
    	if (iTtlNumItems = 0) then
    		Set rsObj = Server.CreateObject("ADODB.Recordset")
    		sSqlTemp = "SELECT COUNT(*) FROM GestioneTbl"
    		rsObj.Open sSqlTemp, conn, 3, 3
    		
    		If Not(rsObj.EOF) Then
    			iTtlNumItems = rsObj(0)
            End If
    					
    		rsObj.Close
    		Set rsObj = Nothing
    	end if
    	
    	iTtlTemp = iTtlNumItems \ iNumPerPage	
    	iDBLocTemp = iDBLoc \ iNumPerPage		
    	
    	If (sQuerystring <> "") Then
    		sURLBeg = "<a href = """ & sURL & "?" & sQuerystring & "&iTtlNumItems=" & iTtlNumItems & "&iDBLoc="
    	Else
    		sURLBeg = "<a href = """ & sURL & "?iTtlNumItems=" & iTtlNumItems & "&iDBLoc="
    	End If
    	
    
    
    	Set rs = Server.CreateObject("ADODB.Recordset")
    	sSql = "SELECT * FROM GestioneTbl"
    	rs.Open sSql, conn, 3, 3
    	
    if not RS.eof then
    
    RecordsXPagina = iNumPerPage
    RS.PageSize = RecordsXPagina
    RS.AbsolutePage = iNumPerPage
    	
    'INIZIO INTESTAZIONI TABELLA
    
     ....
    
    'FINE INTESTAZIONI TABELLA
    
    For i = 1 to RecordsXPagina
    if not RS.eof then
    
    'INIZIO VALORI TABELLA
    
    ...
    
    'FINE VALORI TABELLA
    
    RS.movenext
    end if
    next
    
    
                 
                  
    	if (iDBLoc <> 0) then
    		Response.Write sURLBeg & (iDBLoc - iNumPerPage) & """>Indietro</a>  "
    	end if
    	if (iDBLocTemp >= iNumPerPage) then
    		Response.Write sURLBeg & (( iDBLocTemp \ iNumPerPage ) * iNumPerPage ^ 2) - (iNumPerPage * 9) & """><<</a> "
    	end if
    
    	iA = ( iDBLocTemp \ iNumPerPage ) * iNumPerPage
    	iB = ( iDBLocTemp \ iNumPerPage ) * iNumPerPage + iNumPerPage
    	for x = iA to iB
    		iTemp = (x * iNumPerPage)
    		if (iTemp < iTtlNumItems) then	' takes care of extra numbers after the overall final number
    			if (iDBLoc = iTemp) then
    				Response.Write " [" & x+1 & "]"
    			else
    				Response.Write " " & sURLBeg & (x * iNumPerPage) & """>" & x+1 & "</a>"
    			end if
    		else
    			exit for
    		end if
    	next
    	
    	if (iTtlTemp > iDBLocTemp) then
    		if ((iDBLocTemp + iNumPerPage) <= iTtlTemp) then
    			Response.Write " " & sURLBeg & (( iDBLocTemp \ iNumPerPage ) * iNumPerPage + iNumPerPage ) * iNumPerPage & """>>></a> "
    		end if
    	end if
    	if ((iDBLoc + iNumPerPage) < iTtlNumItems) then
    		Response.Write "  " & sURLBeg & (iDBLoc + iNumPerPage) & """>Avanti</a>"
    	end if
    	
    
                  
    end if
    
    rs.Close
    Set rs = Nothing
    conn.Close
    Set conn = Nothing
    	
    %>
    Lo Stato dà un posto. L’impresa privata dà un lavoro. – Indro Montanelli

  6. #6
    Dubito seriamente che qualcuno abbia voglia di guardare al codice che hai postato

  7. #7
    Utente di HTML.it L'avatar di [trodat]
    Registrato dal
    Oct 2004
    Messaggi
    2,135
    Originariamente inviato da DarioN1
    Dubito seriamente che qualcuno abbia voglia di guardare al codice che hai postato
    quanto sei crudele...
    Lo Stato dà un posto. L’impresa privata dà un lavoro. – Indro Montanelli

  8. #8

  9. #9
    Utente di HTML.it L'avatar di [trodat]
    Registrato dal
    Oct 2004
    Messaggi
    2,135
    Originariamente inviato da DarioN1
    No dai , più che crudele realista
    Eppure ho visto pubblicare codici molto più lunghi e più complessi... non ti va di provarlo?
    Lo Stato dà un posto. L’impresa privata dà un lavoro. – Indro Montanelli

  10. #10
    Utente di HTML.it L'avatar di [trodat]
    Registrato dal
    Oct 2004
    Messaggi
    2,135
    Lo Stato dà un posto. L’impresa privata dà un lavoro. – Indro Montanelli

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.