Visualizzazione dei risultati da 1 a 6 su 6

Discussione: estrazione db

  1. #1

    estrazione db

    Buongiorno,

    Io ho un database che contiene una serie di dati dei vari utenti registrati (nome, cognome, età, ecc.)

    Ho creato una pagina che mi legge questi dati, ma che li legge tutti.
    Se io volessi estrapolare gli utenti nati in un determinato anno, tipo 1980. come faccio?

    Posto il codice che mi legge i dati

    ---------------------
    <%

    Dim conn

    Dim iPageSize

    Dim iPageCount
    Dim iPageCurrent
    Dim strOrderBy

    Dim strSQL
    Dim RS
    Dim iRecordsShown
    iPageSize = 20
    If Request.QueryString("page") = "" Then

    iPageCurrent = 1

    Else

    iPageCurrent = CInt(Request.QueryString("page"))

    End If
    If Request.QueryString("order") = "" Then

    strOrderBy = "id"

    Else

    strOrderBy = Request.QueryString("order")

    End If
    Set Conn = Server.CreateObject("ADODB.Connection")

    conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & server.mappath("../database/dbdisconotte.mdb")

    Set RS = Server.CreateObject("ADODB.Recordset")
    sql = "SELECT * FROM rec_utenti ORDER BY " & strOrderBy & " DESC;"
    RS.Open sql, conn, adOpenKeyset
    RS.PageSize = iPageSize

    RS.CacheSize = iPageSize

    iPageCount = RS.PageCount
    If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
    If iPageCurrent < 1 Then iPageCurrent = 1
    If iPageCount = 0 Then

    Response.Write("NESSUN UTENTE REGISTRATO!")
    Else

    RS.AbsolutePage = iPageCurrent
    iRecordsShown = 0

    Do While iRecordsShown < iPageSize And Not RS.EOF

    %>

    <div align="left">

    <table border="0" cellpadding="0" cellspacing="0" width="1246" style="border-collapse: collapse" bordercolor="#111111" height="39">
    <tr>

    <td width="28" style="border-right:1px solid #FFFFFF; border-left:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">
    </td>

    <td width="28" style="border-right:1px solid #FFFFFF; border-left:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">
    </td>

    <td width="28" style="border-right:1px solid #FFFFFF; border-left:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">
    </td>

    <td width="86" style="border-right:1px solid #FFFFFF; border-left:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">


    <font face="Verdana" color="#FFFFFF">N.</font><font color="#FFFFFF"> </font>
    </td>

    <td width="99" style="border-left: 1px solid #FFFFFF; border-right: 1px solid #FFFFFF; border-top: 1px solid #000080; " align="center" bgcolor="#000080" height="20">


    <font face="Verdana" color="#FFFFFF">DATA</font><font color="#FFFFFF">
    </font>
    </td>

    <td width="234" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">


    <font face="Verdana" color="#FFFFFF">NOME</font><font color="#FFFFFF">
    </font>
    </td>

    <td width="182" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">


    <font face="Verdana" color="#FFFFFF">COGNOME</font><font color="#FFFFFF">
    </font>

    </td>

    <td width="42" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">


    <font face="Verdana" color="#FFFFFF">SESSO</font><font color="#FFFFFF">
    </font>


    </td>

    <td width="24" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">


    <font face="Verdana" color="#FFFFFF">GG </font>


    </td>

    <td width="24" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">


    <font face="Verdana" color="#FFFFFF">MM</font></td>

    <td width="41" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">


    <font face="Verdana" color="#FFFFFF">ANNO</font></td>

    <td width="234" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">


    <font face="Verdana" color="#FFFFFF">INDIRIZZO</font><font color="#FFFFFF">
    </font>


    </td>

    <td width="29" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">


    <font face="Verdana" color="#FFFFFF">N.</font><font color="#FFFFFF">
    </font>


    </td>

    <td width="299" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">


    <font face="Verdana" color="#FFFFFF">COMUNE</font><font color="#FFFFFF">
    </font>


    </td>

    <td width="55" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">


    <font face="Verdana" color="#FFFFFF">CAP</font><font color="#FFFFFF">
    </font>


    </td>

    <td width="59" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">


    <font color="#FFFFFF" face="Verdana">PROVINCIA</font></td>

    <td width="149" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">


    <font face="Verdana" color="#FFFFFF">CELLULARE</font></td>




    <td width="257" style="border-left:1px solid #FFFFFF; border-right:1px solid #FFFFFF; border-top:1px solid #000080; " align="center" bgcolor="#000080" height="20">


    <font face="Verdana" color="#FFFFFF">EMAIL</font></td>




    </tr>
    <tr>

    <td width="18" style="border-left: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19" valign="middle">
    <p align="center">
    ">[img]cancella.gif[/img]
    </td>

    <td width="18" style="border-left: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19" valign="middle">
    <p align="center">
    ">[img]modifica.gif[/img]
    </p>
    </td>

    <td width="27" style="border-left: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19" valign="middle">
    <p align="center">
    <a style="text-decoration: none" href="invio_mail_riduzioni.asp?cod=<%=rs("id")%>">
    [img]email.jpg[/img]</a></td>

    <td width="86" style="border-left: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
    <p align="center"><font face="Verdana" style="font-size: 8pt"><% response.write(rs("id"))%>
    </font>

    </td>

    <td width="99" style="border: 1px solid #000080; " height="19">
    <font face="Verdana" style="font-size: 8pt"><% response.write(rs("iscrizione"))%>
    </font>
    </td>

    <td width="234" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
    <font face="Verdana" style="font-size: 8pt"><% response.write(rs("nome"))%>
    </font>
    </td>

    <td width="182" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
    <font face="Verdana" style="font-size: 8pt"><% response.write(rs("cognome"))%>
    </font>

    </td>

    <td width="42" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
    <p align="center">
    <font face="Verdana" style="font-size: 8pt"><% response.write(rs("sesso"))%>
    </font>


    </td>

    <td width="24" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
    <font face="Verdana" style="font-size: 8pt"><% response.write(rs("gg"))%>
    </font>


    </td>

    <td width="24" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
    <font face="Verdana" style="font-size: 8pt"><% response.write(rs("mm"))%>
    </font>
    </td>

    <td width="41" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
    <font face="Verdana" style="font-size: 8pt"><% response.write(rs("anno"))%>
    </font>
    </td>

    <td width="234" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
    <font face="Verdana" style="font-size: 8pt"><% response.write(rs("indirizzo"))%>
    </font>


    </td>

    <td width="29" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
    <font face="Verdana" style="font-size: 8pt"><% response.write(rs("ncivico"))%>
    </font>


    </td>

    <td width="299" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
    <font face="Verdana" style="font-size: 8pt"><% response.write(rs("comune"))%>
    </font>


    </td>

    <td width="55" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
    <font face="Verdana" style="font-size: 8pt"><% response.write(rs("cap"))%>
    </font>


    </td>

    <td width="59" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
    <p align="center"><% response.write(rs("provincia"))%>
    </td>

    <td width="149" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
    <p align="center"><font face="Verdana" style="font-size: 8pt"><% response.write(rs("cellulare"))%>
    </font>
    </td>




    <td width="257" style="border-right: 1px solid #000080; border-top: 1px solid #000080; border-bottom: 1px solid #000080; " height="19">
    <p align="center"><% response.write(rs("email"))%>
    </td>




    </tr>
    </table>
    </div>




    </p>
    <p align="center">
    <%

    iRecordsShown = iRecordsShown + 1
    RS.MoveNext
    Loop




    RS.Close

    Set RS = Nothing

    Conn.Close %>
    <%

    If iPageCurrent <> 1 Then

    %>


    <div align="center">
    <center>
    <table border="0" cellpadding="0" cellspacing="0" width="1000">
    <tr>
    <td width="161">



    <font face="Verdana">
    Indietro</font>

    <%

    End If

    %>

    <%

    If iPageCurrent < iPageCount Then

    %> <font face="Verdana">
    <a href="elenco_riduzioni.asp?page=<%= iPageCurrent + 1 %>&order=<%= Server.URLEncode(strOrderBy) %>">Avanti
    </a>
    </font>
    </td>
    <td width="739">
    <p align="right"><font face="Verdana" color="#000080"><a href="admin.asp">TORNA
    ADMIN</a></font><a href="admin.asp"><%

    End If

    %

    -----------------------------------------------------

    Grazie

  2. #2
    "SELECT * from ciccio where datepart('yyyy',campodata)=" & valorechecerchi;

  3. #3
    mi da questo errore

    Microsoft VBScript compilation error '800a03f6'

    Expected 'End'

    /admin/elenco_riduzioni_80.asp, line 371

  4. #4
    posta la riga dell'errore ...

  5. #5
    End If

  6. #6
    ne manca forse uno proprio alla fine ... solo che il tuo codice così postato faccio fatica a leggerlo ...
    da quanto son riuscito a vedere hai lasciato questo aperto:

    If iPageCount = 0 Then

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.