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

    problema visualizzazione prodotti di un db

    Da una index di un e commerce voglio andare ad una pagina che mi elenca i prodotti in dinamico.
    Ho creato un database con una tabella "parco_auto" e vorrei vedere tutti i record.
    Ho fatto in questo modo ma nn mi da nè errore nè però riesco a visualizzare niente.
    Qualcuno mi può dare una mano... Grazie!!


    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <!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>offerta</title>
    <link href="alcars.css" rel="stylesheet" type="text/css" />
    </head>

    <body>
    <center>
    <table width="770" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td align="center">[img]img/header.gif[/img]</td>
    </tr>
    </table>
    <table width="770" cellpadding="0" cellspacing="0">
    <tr>
    <td width="150" align="left" valign="top" bgcolor="#E5E5E5">


    > chi siamo

    > offerta

    > services

    > assistenza

    > link

    > contatti</p>
    td>
    <td width="470" align="CENTER" valign="top">
    <%
    set dbconn = server.createobject("adodb.connection")
    dbconn.open(application("strconn"))
    set rstparco_auto = server.createobject("adodb.recordset")
    dim sql
    sql = "select * from parco_auto "
    set rstcategorie = dbconn.execute(sql)
    dbconn.close
    %>
    </td>
    </tr>
    </table>
    </center>
    </body>
    </html>

  2. #2
    ragà una mano perfavore

  3. #3
    Utente di HTML.it L'avatar di Lak3d
    Registrato dal
    Aug 2006
    Messaggi
    1,031
    codice:
     set rstcategorie = dbconn.execute(sql)
    dbconn.close
    Che fai? apri il recordset e chiudi la connessione senza stampare nulla?
    Devi fare una cosa di questo tipo:

    codice:
    <%
    Set dbconn = server.createobject("adodb.connection")
    dbconn.Open(application("strconn"))
    Set rstCategorie = server.createobject("adodb.recordset")
    dim sql
    SQL = "SELECT * FROM parco_auto"
    set rstCategorie = dbconn.Execute(SQL)
    
    if not rstCategorie.EOF then
       response.write "<TABLE BORDER=0><tr>"
       For i=0 to rstCategorie.Fields.Count-1
          response.write "<td>" & rstCategorie.fields(i).Name & "</td>" 
       Next
       response.write "</tr>"
       
       rstCategorie.MoveFirst
       While not rstCategorie.EOF
          response.write "<tr>"
          For i=0 to rstCategorie.Fields.Count-1
             response.write "<td>" & rstCategorie(i) & "</td>"
          Next
          response.write "</tr>"
          rstCategorie.MoveNext
       Wend  
       response.write "</TABLE>"
    End if
    
    Set rstCategorie=Nothing
    dbconn.Close
    %>
    L'ho scritto di getto, potrebbe contenere strafalcioni

  4. #4
    infatti mi da questo errore:

    Tipo di errore:
    Errore di run-time di Microsoft VBScript (0x800A01A8)
    Necessario oggetto: ''
    /corso_asp/alcars/offerta.asp, line 38

  5. #5
    Utente di HTML.it L'avatar di Lak3d
    Registrato dal
    Aug 2006
    Messaggi
    1,031
    la linea 38 cosa contiene?

    Se riguarda la connessione al db che hai usato tu, forse contiene errori... copia questa che va sicuramente bene... (ovviamente aggiungici la directory al tuo database)

    codice:
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.Open("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\... .mdb")
    Set rstCategorie=objConn.Execute(SQL)
    Se invece riguarda qualche script che hai inserito tu devi postare il codice della riga 38

  6. #6
    ti posto l'intero codice:


    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <!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>Untitled Document</title>
    <link href="alcars.css" rel="stylesheet" type="text/css" />
    </head>

    <body>
    <center>
    <table width="770" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td align="center">[img]img/header.gif[/img]</td>
    </tr>
    </table>
    <table width="770" cellpadding="0" cellspacing="0">
    <tr>
    <td width="150" align="left" valign="top" bgcolor="#E5E5E5">


    > chi siamo

    > offerta

    > services

    > assistenza

    > link

    > contatti</p>


    </p>


    </p>


    </p></td>
    <td width="470" align="CENTER" valign="top">
    <%
    Set dbconn = server.createobject("adodb.connection")
    dbconn.Open(application("strconn"))
    Set rstCategorie = server.createobject("adodb.recordset")
    dim sql
    SQL = "SELECT * FROM parco_auto"
    set rstCategorie = dbconn.Execute(SQL)

    if not rs.EOF then
    response.write "<TABLE BORDER=0><tr>"
    For i=0 to rs.Fields.Count-1
    response.write "<td>" & rstcategorie.fields(i).Name & "</td>"
    Next
    response.write "</tr>"

    rstCategorie.MoveFirst
    While not rs.eof
    response.write "<tr>"
    For i=0 to rstCategorie.Fields.Count-1
    response.write "<td>" & rstCategorie(i) & "</td>"
    Next
    response.write "</tr>"
    rs.MoveNext
    Wend
    response.write "</TABLE>"
    End if

    set rstCategorie=Nothing
    dbconn.Close
    %>


    </td>
    <td align="center" valign="top" bgcolor="#E5E5E5" width="150"><span class="menu">AREA RISERVATA</span>
    <table width="100%" border="0">
    <form method="post"action="controllo_login.asp">
    <tr>
    <td align="center" valign="top"><input type="text" id="user" name="user" class="menu"></td>
    </tr>
    <tr>
    <td align="center" valign="top"><input type="password" id="pwd" name="pwd" class="menu"></td>
    </tr>
    <tr>
    <td align="center" valign="top"><input type="submit" id="vai" value="entra"></td>
    </tr>
    </form>
    </table> </td>
    </tr>
    </table>
    <table width="770" cellpadding="0" cellspacing="0" bgcolor="#E5E5E5">
    <tr>
    <td align="center" valign="middle" class="menu">Copyright 2006 Alcars srl Via Del Gallitello 39, 85100 Potenza, PZ -Basilicata</td>
    </tr>
    </table>


    </center>
    </body>
    </html>

  7. #7
    Utente di HTML.it L'avatar di Lak3d
    Registrato dal
    Aug 2006
    Messaggi
    1,031
    che database stai usando? Manca anche la stringa di connessione al database.
    Usa la seconda che ti ho postato mettendoci l'indirizzo del tuo db.

    codice:
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.Open("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\... .mdb")
    Set rstCategorie = server.createobject("adodb.recordset")
    dim SQL
    SQL = "SELECT * FROM parco_auto"
    set rstCategorie = ObjConn.Execute(SQL)
    
    if not rstCategorie.EOF then
       response.write "<TABLE BORDER=0><tr>"
       For i=0 to rstCategorie.Fields.Count-1
          response.write "<td>" & rstCategorie.fields(i).Name & "</td>" 
       Next
       response.write "</tr>"
       
       rstCategorie.MoveFirst
       While not rstCategorie.EOF
          response.write "<tr>"
          For i=0 to rstCategorie.Fields.Count-1
             response.write "<td>" & rstCategorie(i) & "</td>"
          Next
          response.write "</tr>"
          rstCategorie.MoveNext
       Wend  
       response.write "</TABLE>"
    End if
    
    Set rstCategorie=Nothing
    dbconn.Close
    %>
    Questo, una volta inserita la directory del tuo db non può non funzionare. A meno ovviamente di errori che ho fatto io scrivendolo. Cose abbastanza semplici da sistemare in ogni caso...

    Se ti da errori su altre righe, usa un editor di testo serio che te le indichi, in modo da arrivare subito all'errore.

  8. #8
    La stringa di connessione è contenuta nel global asa.
    Cmq io l'ho copiata e riscritta all'interno del file in questo modo, ma nn funziona!!!


    <%
    Set dbconn = server.createobject("adodb.connection")
    dbconn.Open("Provider=SQLOLEDB.1;Password=francesc o;Persist Security Info=True;User ID=francesco;Initial Catalog=francesco;Data Source=DESKTOP\sqlexpress")
    Set rstCategorie = server.createobject("adodb.recordset")
    dim sql
    SQL = "SELECT * FROM parco_auto"
    set rstCategorie = dbconn.Execute(SQL)

    if not rs.EOF then
    response.write "<TABLE BORDER=0><tr>"
    For i=0 to rs.Fields.Count-1
    response.write "<td>" & rstcategorie.fields(i).Name & "</td>"
    Next
    response.write "</tr>"

    rstCategorie.MoveFirst
    While not rs.eof
    response.write "<tr>"
    For i=0 to rstCategorie.Fields.Count-1
    response.write "<td>" & rstCategorie(i) & "</td>"
    Next
    response.write "</tr>"
    rs.MoveNext
    Wend
    response.write "</TABLE>"
    End if

    set rstCategorie=Nothing
    dbconn.Close
    %>

  9. #9
    Utente di HTML.it L'avatar di Lak3d
    Registrato dal
    Aug 2006
    Messaggi
    1,031
    ah, è SQLServer... mai usato, però credo che una volta che usi la stringa di connessione adatta tutto rimanga invariato... ma cosa contiene la riga sulla quale è specificato l'errore?

  10. #10
    Premetto che il codice lo sto aprendo cn dreamweaver quindi nn so se la riga in questione corrisponda.. cmq contiene "dbconn.Close"

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.