Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2005
    Messaggi
    69

    errore ricerca record non presente

    ciao a tutti
    vengo al problema

    ho un box per la ricerca di auto con 3 form, ognuno con un campo
    id, marca, modello
    ora il problema si presenta quando la ricerca non restituisce un record valido, ma solo con la pagina dei risultati della ricerca per id
    se inserisco un id non presente nel database mi restituisce il seguente messaggio

    Error Type:
    ADODB.Field (0x800A0BCD)
    Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
    /car/pannello/ricerca_risultato_id.asp, line 196

    la linea 196 è questa

    <td><h4><%=(rs_ricerca_id.Fields.Item("id_ctl").Va lue)%></h4></td>

    posto anche la dichiarazione della variabile

    <%
    Dim rs_ricerca_id__MMColParam
    rs_ricerca_id__MMColParam = "1"
    If (Request.QueryString("id_ctl") <> "") Then
    rs_ricerca_id__MMColParam = Request.QueryString("id_ctl")
    End If
    %>

    qualcuno ha un idea del problema?
    grazie ciao

  2. #2
    Utente di HTML.it L'avatar di fiber81
    Registrato dal
    Oct 2002
    Messaggi
    328
    Non mi è tanto chiaro, come fa a non esistere rs_ricerca_id.Fields.Item("id_ctl").Value se è il risultato di una query? Fai un controllo quando cicli se sei alla fine del recodset?
    Prova a postare un pò più di codice.
    Ci sono 10 tipi di persone al mondo, quelli che conoscono la numerazione binaria e quelli che non la conoscono!

  3. #3
    Utente di HTML.it
    Registrato dal
    Jan 2005
    Messaggi
    69
    il problema me lo da solo quando inserisco nella ricerca un id non presente nel database, ti posto il codice intero della pagina

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

    <%
    Dim rs_ricerca_id__MMColParam
    rs_ricerca_id__MMColParam = "1"
    If (Request.QueryString("id_ctl") <> "") Then
    rs_ricerca_id__MMColParam = Request.QueryString("id_ctl")
    End If
    %>
    <%
    Dim rs_ricerca_id
    Dim rs_ricerca_id_numRows

    Set rs_ricerca_id = Server.CreateObject("ADODB.Recordset")
    rs_ricerca_id.ActiveConnection = MM_car_conn_catalogo_STRING
    rs_ricerca_id.Source = "SELECT id_ctl, marca_ctl, modello_ctl, tipo_ctl FROM catalogo_ctl WHERE id_ctl = " + Replace(rs_ricerca_id__MMColParam, "'", "''") + ""
    rs_ricerca_id.CursorType = 0
    rs_ricerca_id.CursorLocation = 2
    rs_ricerca_id.LockType = 1
    rs_ricerca_id.Open()

    rs_ricerca_id_numRows = 0
    %>
    <%
    ' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

    Dim rs_ricerca_id_total
    Dim rs_ricerca_id_first
    Dim rs_ricerca_id_last

    ' set the record count
    rs_ricerca_id_total = rs_ricerca_id.RecordCount

    ' set the number of rows displayed on this page
    If (rs_ricerca_id_numRows < 0) Then
    rs_ricerca_id_numRows = rs_ricerca_id_total
    Elseif (rs_ricerca_id_numRows = 0) Then
    rs_ricerca_id_numRows = 1
    End If

    ' set the first and last displayed record
    rs_ricerca_id_first = 1
    rs_ricerca_id_last = rs_ricerca_id_first + rs_ricerca_id_numRows - 1

    ' if we have the correct record count, check the other stats
    If (rs_ricerca_id_total <> -1) Then
    If (rs_ricerca_id_first > rs_ricerca_id_total) Then
    rs_ricerca_id_first = rs_ricerca_id_total
    End If
    If (rs_ricerca_id_last > rs_ricerca_id_total) Then
    rs_ricerca_id_last = rs_ricerca_id_total
    End If
    If (rs_ricerca_id_numRows > rs_ricerca_id_total) Then
    rs_ricerca_id_numRows = rs_ricerca_id_total
    End If
    End If
    %>

    <%
    ' *** Recordset Stats: if we don't know the record count, manually count them

    If (rs_ricerca_id_total = -1) Then

    ' count the total records by iterating through the recordset
    rs_ricerca_id_total=0
    While (Not rs_ricerca_id.EOF)
    rs_ricerca_id_total = rs_ricerca_id_total + 1
    rs_ricerca_id.MoveNext
    Wend

    ' reset the cursor to the beginning
    If (rs_ricerca_id.CursorType > 0) Then
    rs_ricerca_id.MoveFirst
    Else
    rs_ricerca_id.Requery
    End If

    ' set the number of rows displayed on this page
    If (rs_ricerca_id_numRows < 0 Or rs_ricerca_id_numRows > rs_ricerca_id_total) Then
    rs_ricerca_id_numRows = rs_ricerca_id_total
    End If

    ' set the first and last displayed record
    rs_ricerca_id_first = 1
    rs_ricerca_id_last = rs_ricerca_id_first + rs_ricerca_id_numRows - 1

    If (rs_ricerca_id_first > rs_ricerca_id_total) Then
    rs_ricerca_id_first = rs_ricerca_id_total
    End If
    If (rs_ricerca_id_last > rs_ricerca_id_total) Then
    rs_ricerca_id_last = rs_ricerca_id_total
    End If

    End If
    %>
    <%
    Dim MM_paramName
    %>
    <%
    ' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

    Dim MM_keepNone
    Dim MM_keepURL
    Dim MM_keepForm
    Dim MM_keepBoth

    Dim MM_removeList
    Dim MM_item
    Dim MM_nextItem

    ' create the list of parameters which should not be maintained
    MM_removeList = "&index="
    If (MM_paramName <> "") Then
    MM_removeList = MM_removeList & "&" & MM_paramName & "="
    End If

    MM_keepURL=""
    MM_keepForm=""
    MM_keepBoth=""
    MM_keepNone=""

    ' add the URL parameters to the MM_keepURL string
    For Each MM_item In Request.QueryString
    MM_nextItem = "&" & MM_item & "="
    If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
    MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.QueryString(MM_item))
    End If
    Next

    ' add the Form variables to the MM_keepForm string
    For Each MM_item In Request.Form
    MM_nextItem = "&" & MM_item & "="
    If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
    MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.Form(MM_item))
    End If
    Next

    ' create the Form + URL string and remove the intial '&' from each of the strings
    MM_keepBoth = MM_keepURL & MM_keepForm
    If (MM_keepBoth <> "") Then
    MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
    End If
    If (MM_keepURL <> "") Then
    MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
    End If
    If (MM_keepForm <> "") Then
    MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
    End If

    ' a utility function used for adding additional parameters to these strings
    Function MM_joinChar(firstItem)
    If (firstItem <> "") Then
    MM_joinChar = "&"
    Else
    MM_joinChar = ""
    End If
    End Function
    %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Risultato ricerca codice</title>
    <link rel="stylesheet" type="text/css" href="/car/css/car_comune.css" />
    <link rel="stylesheet" type="text/css" href="/car/css/car_base.css" />
    <link rel="stylesheet" type="text/css" href="/car/css/car_pannello.css" />
    <link rel="stylesheet" type="text/css" href="/car/css/car_col_sx.css" />
    <link rel="stylesheet" type="text/css" href="/car/css/car_footer.css" />
    </head>

    <body>
    <div id="contenitore">
    <div id="testata"></div>
    <div id="wrapper_col_dx">

    <div id="col_dx">
    <div id="testo_sezioni_pannello">

    </div>

    <div class="tabella_elenco_pannello">
    <div class="titolo_tabella_elenco_pannello">
    <h2>Risultato della ricerca per codice </h2>
    </div>

    <table width="100%">
    <tr>
    <td><h3>codice</h3></td>
    <td><h3>marca</h3></td>
    <td><h3>modello</h3></td>
    <td><h3>tipo</h3></td>
    <td><h3>modifica</h3></td>
    <td><h3>elimina</h3></td>
    </tr>
    <tr bgcolor="<%=bgcol%>">
    <td><h4><%=(rs_ricerca_id.Fields.Item("id_ctl").Va lue)%></h4></td>
    <td><h4><%=(rs_ricerca_id.Fields.Item("marca_ctl") .Value)%></h4></td>
    <td><h4>"><%=(rs_ricerca_id.Fields.Item("modello_ctl").Val ue)%></h4></td>
    <td><h4><%=(rs_ricerca_id.Fields.Item("tipo_ctl"). Value)%></h4></td>
    <td><h4>">vai</h4></td>
    <td><h4>">vai</h4></td>
    </tr>
    </table>
    <div class="navigazione_risultati">


    </div>
    </div>
    <div>
    <% If rs_ricerca_id.EOF And rs_ricerca_id.BOF Then %>
    <h2>La ricerca non ha prodotto risultati</h2>
    <% End If ' end rs_ricerca_id.EOF And rs_ricerca_id.BOF %>
    </div>
    </div>
    </div>

    <div id="col_sx">

    </div>


    <div id="footer"></div>
    </div>
    </body>
    </html>
    <%
    rs_ricerca_id.Close()
    Set rs_ricerca_id = Nothing
    %>

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 © 2026 vBulletin Solutions, Inc. All rights reserved.