Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it L'avatar di ISE
    Registrato dal
    Sep 2003
    Messaggi
    1,314

    Connessione db + lettura

    Ragazzi vorrei vorrei far leggere dei dati presenti in un database...
    per fare un prova ho creato tutto in maniera molto semplice.
    Ho fatto una tabella a 4 colonne dove volevo far leggere i dati ed ho inserito questo codice:
    codice:
    <%@LANGUAGE="VBSCRIPT"%>
    <%
    Set Con = Server.CreateObject( "ADODB.Connection" )
    Con.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&SERVER.MAPPATH("/mdb-database/prova.mdb")
    
    Set rs = Server.CreateObject( "ADODB.Recordset" )
    rs.Open SQL,Con, 2,1
    %> 
    <html>
    <head>
    <title>Documento senza titolo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    <table width="500" border="0" align="center">
      <tr bgcolor="#CCCCCC"> 
        <td>Nome</td>
        <td>Cognome</td>
        <td>Età</td>
        <td>Telefono</td>
    
      </tr>
    <% while not rs.eof %> 
      <tr bgcolor="#CCCCCC"> 
        <td><%= rs("nome") %></td>
        <td><%= rs("cognome") %></td>
        <td><%= rs("eta") %></td>
        <td><%= rs("telefono") %></td>
        <td></td>   </tr>
    <% 
    rs.movenext
    wend
    %> 
    </table>
    <%
    rs.close
    set rs = nothing
    con.close
    set con = nothing
    %> 
    </body>
    </html>
    Premetto che ho trovato un esempio pronto e quello scritto in verde non so a cosa serva...

    Qualcuno può dirmi cosa c'è di sbagliato?

  2. #2

  3. #3
    Utente di HTML.it L'avatar di ISE
    Registrato dal
    Sep 2003
    Messaggi
    1,314
    ??????
    Cioè?

  4. #4
    Moderatore di CMS L'avatar di kalosjo
    Registrato dal
    Jul 2001
    residenza
    In culo alla luna
    Messaggi
    1,999
    rs.Open SQL,Con, 2,1

    Non hai definito SQL

    dovresti scrivere prima

    SQL="select * from nometabella"

    Quello scritto in verde è codice vbscript che scorre il recordset e alla fine lo chiude.
    Scusate i puntini di sospensione...... La verità è che non ho argomenti....

  5. #5
    Utente di HTML.it L'avatar di ISE
    Registrato dal
    Sep 2003
    Messaggi
    1,314
    codice:
    <%
    Set Con = Server.CreateObject( "ADODB.Connection" )
    Con.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&SERVER.MAPPATH("/mdb-database/prova.mdb")
    
    Set rs = Server.CreateObject( "ADODB.Recordset" )
    SQL="select * from elenco"
    rs.Open SQL,Con, 2,2
    %>
    Scritto così va bene?

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.