Visualizzazione dei risultati da 1 a 6 su 6

Discussione: E-commerce in ASP

  1. #1
    Utente di HTML.it
    Registrato dal
    Sep 2004
    Messaggi
    1,344

    E-commerce in ASP

    Ho seguito una guida per creare una carrello in ASP, però mi dà un errore che non riesco a scovare...qualcuno mi aiuta?
    Sono in questa pagina e cliccando su acquista mi manda a CAR.ASP che però nnon funziona perchè viene scritto IMPOSSIBILE VISUALIZZARE LA PAGINA


    PROD.ASP

    <%@ LANGUAGE = VBSCRIPT %>
    <%
    'recuperiamo l'id del prodotto e lo assegnamo ad una nuova variabile
    id = request.querystring("id")
    'apriamo connessione e recordset
    Set connprod = Server.CreateObject("ADODB.Connection")
    conn_prod = "PROVIDER = Microsoft.Jet.Oledb.4.0; Data Source ="&_
    server.mappath("negozio.mdb")
    connprod.open conn_prod
    Set rsprod = server.createobject("adodb.recordset")
    sqlprod = "SELECT * FROM prodotti WHERE prod_id = "&id&""
    rsprod.open sqlprod, connprod
    %>
    <html><head><title>Esempio di sito E-Commerce</title></head>
    <body topmargin="0" leftmargin="0" bgcolor="#FFFFFF">
    <div align="center">
    <center>
    <table border="0" width="780" cellspacing="0" cellpadding="0" height="0">
    <tr>
    <td width="411" height="10">
    <p align="center"><font face="Verdana" color="#FF0000">Corso on-line di ************ e Guidainlinea.com</font></td>
    </center>
    <td width="365" height="10"></td>
    </tr>
    </table>
    <table border="0" width="780" cellspacing="0" cellpadding="0" height="0">
    <center>
    <tr>
    <td width="776" height="9" colspan="2">
    <p align="center"></td>
    </tr>
    <tr>
    <td width="309" height="10">
    <p align="center"><font size="2" face="verdana">Motore di ricerca</font></p>
    </td>
    <td width="467" rowspan="6" height="45" align="right" valign="TOP">
    <p align="center">[img]img/<%=rsprod([/img].gif"></p>
    <%=rsprod("prod_nome")%>

    <%=rsprod("prod_descc")%>

    costo: <%=rsprod("prod_prezzo")%> €



    <form method=post action=car.asp>
    <input type=hidden name=id value="<%=rsprod("prod_id")%>">
    <input type=hidden name=nome value="<%=rsprod("prod_nome")%>">
    <input type=hidden name=prezzo value="<%=rsprod("prod_prezzo")%>">
    <p align=center><input type=submit value=Acquista></p>
    </form>

    </td>
    </tr>
    <tr>
    <td width="309" height="9">
    <form method=get action=ricerca.asp>
    <p align="center">
    <input type=text name=cerca>

    <input type=submit value=Cerca>
    </form>
    </td>
    </tr>
    <tr>
    <td width="309" height="19"></td>
    </tr>
    <tr>
    <td width="309" height="1">
    <p align="center"><font size="2" face="verdana">Categorie:</font></td>
    </tr>
    <tr>
    <td width="309" height="0" valign="TOP">

    </td>
    </tr>
    <tr>
    <td width="309" height="0"></td>
    </tr>
    </table>
    </center>
    </div>
    </body></html>
    <%
    'chiudiamo connessione e recordset liberando risorse
    rsprod.close

    Set rsprod = NOTHING
    connprod.close
    Set connprod = NOTHING
    %>

    CAR.ASP

    <% Response.Buffer = TRUE %>


    <%
    'ricevi ed assegna un valore alle variabili
    ID = Request("id")
    username = TRIM(Request("username"))
    password = TRIM(Request("password"))
    reg = Request("reg")
    'apri connessione
    Set Con = Server.CreateObject( "ADODB.Connection" )
    str_conn = "Provider =microsoft.jet.oledb.4.0; data source="&_
    server.mappath("negozio.mdb")
    Con.open str_conn

    'se reg ha valore vuol dire che qualcuno si e’ registrato ed aggiungi i dati nel database
    if reg <> "" then
    newnome = Request("newnome")
    newcognome = Request("newcognome")
    newusername = Request("newusername")
    newpassword = Request("newpassword")
    newemail = Request("newemail")
    newindirizzo = Request("newindirizzo")
    newcitta = Request("newcitta")
    newcap = Request("newcap")
    newprov = Request("newprov")
    sqlString = "SELECT utenti_username FROM utenti WHERE utenti_username =
    '"&fixQuotes(theUsername)&"'"
    set rs = Con.Execute( sqlString )
    if rs.eof then
    response.write "<font face=Verdana size=2>Non puoi utilizzare questo username perchè già in
    uso!</font>"
    else
    response.write "non esiste"
    end if
    rs.Close
    Set rs = Nothing
    sqlString = "INSERT INTO utenti (utenti_nome, utenti_cognome, utenti_username,
    utenti_password, utenti_email, utenti_ind, utenti_citta, utenti_cap, utenti_prov) VALUES
    ('"&fixQuotes(newnome)&"', '"&fixQuotes(newcognome)&"', '"&fixQuotes(newusername)&"',
    '"&fixQuotes(newpassword)&"', '"&fixQuotes(newemail)&"', '"&fixQuotes(newindirizzo)&"',
    '"&fixQuotes(newcitta)&"', "&newcap&", '"&fixQuotes(newprov)&"')"
    Con.Execute sqlString
    username = newusername
    password = newpassword
    ' questa e’ una funzione che crea i cookies
    addCookie "username", username
    addCookie "password", password
    end if
    ' altra funzione che verifica la password
    userID = checkpassword( username, password, Con )
    'in base alla funzione precedente verifica quale pagina includere
    if userID > 0 then %>

    <% else %>

    <% end if %>

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Disabilita gli errori HTTP brevi dal menu strumenti --> opzioni internet --> avanzate di Ineternet Explorer.
    E poi fai ripartire la pagina per leggere l'errore.

    Roby

  3. #3
    Utente di HTML.it
    Registrato dal
    Sep 2004
    Messaggi
    1,344
    Grande! Così ho risolto almeno 10 errori... però adesso mi sono bloccato di nuovo. Mi da questo errore...

    Microsoft JET Database Engine error '80004005'

    Operation must use an updateable query.

    /carrello/carrello.asp, line 21

    e questo è il listato

    <%
    'Variabile prod_id
    prod_id = TRIM(Request("id"))
    if prod_id <> "" then

    'Seleziona il prodotto dal carrello
    sqlString = "SELECT car_id FROM car WHERE car_ut_id = "&userid&" AND car_prod_id ="&prod_id
    set rs = Con.Execute(sqlString)
    if rs.eof then

    'Se il prodotto non è presente, crea un nuovo record
    sqlString = "INSERT INTO car (car_ut_id, car_prod_id, car_quan) VALUES ("&userid&", "&prod_id&", 1)"
    else

    'Se il prodotto è presente incrementa di uno il valore
    sqlString = "UPDATE car SET car_quan = car_quan + 1 WHERE car_id = "&rs("car_id")
    end if

    rs.Close
    set rs = Nothing
    Con.Execute sqlString
    end if

    'Aggiorniamo la quantità del prodotto o cancelliamolo del tutto...
    if Request("updateQ") <> "" THEN
    set rs = Server.CreateObject("ADODB.Recordset")
    sqlString = "SELECT car_id, car_quan FROM car WHERE car_ut_id = "&userid
    rs.Open sqlString, str_conn, 3, 3
    while not rs.eof
    newQ = TRIM(Request("pq"&RS("car_id")))
    if newQ = "" OR newQ = "0" then
    rs.delete
    else
    if isNumeric(newQ) then
    rs("car_quan") = newQ
    end if
    end if
    rs.movenext
    wend
    rs.close
    set rs = Nothing
    end if
    %>
    <html>
    <head><title>Carrello</title></head>
    <body bgcolor="#FFFFFF">
    <center>
    <font face="Verdana" size=2>Ciao <%=username%> questo è il tuo carrello:</font>
    <%
    'Apriamo recordset per invio dati relativi al carrello in output
    sqlString = "SELECT car_id, prod_nome, prod_prezzo, car_quan FROM car, prodotti WHERE car_ut_id = "&userid&" AND car_prod_id = prod_id ORDER BY car_id DESC"
    set rs = con.execute( sqlString )
    if rs.eof then
    %>


    <font face="verdana" size="2">Nessun prodotto presente nel tuo carrello!</font>[/b]



    <form action="default.asp">
    <input type="submit" value="Continua acquisti">
    </form>
    <%
    else
    ordine = 0
    %>
    <form method="post" action="car.asp">
    <input name="updateQ" type="hidden" value="1">
    <input name="username" type="hidden" value="<%=username%>">
    <input name="password" type="hidden" value="<%=password%>">
    <table border=1 cellpadding=4 cellspacing=0>
    <tr>
    <td><p align=center><font face=verdana size=2>Prodotto</font></p></td>
    <td><p align=center><font face=verdana size=2>Prezzo</font></p></td>
    <td><p align=center><font face=verdana size=2>Quantità </font></p></td>
    </tr>
    <%
    while not rs.eof
    ordine = ordine + (RS("prod_prezzo") * RS("car_quan"))
    %>
    <tr><td><font face=verdana
    size=2><%=Server.HTMLEncode(RS("prod_nome"))%></font></td>
    <td><p align=right><font face=verdana
    size=2><%=formatCurrency(RS("prod_prezzo"))%></font></p></td>
    <td><p align=right><input name="pq<%=rs("car_id")%>" type="text" size=2
    value="<%=rs("car_quan")%>"></p></td></tr>
    <%
    rs.movenext
    wend
    %>
    <tr><td colspan=2 align=right><font face=verdana size=2>Valore ordine
    totale:</font>
    </td>
    <td><p align=right><font face=verdana
    size=2><%=formatCurrency(ordine)%></font></p></td></tr>
    <tr><td colspan=3>
    <table border=0>
    <tr><td align="right">
    <input type="submit" value="Aggiorna carrello">
    </td>
    </form>
    <form method="post" action="checkout.asp">
    <input name="username" type="hidden" value="<%=username%>">
    <input name="password" type="hidden" value="<%=password%>">
    <td>
    <input type="submit" value="Termina ordine">
    </td>
    </form>
    <form action="default.asp">
    <td>
    <input type="submit" value="Continua acquisti">
    </td>
    </form>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <% end if %>
    </center>
    </body>
    </html>
    <%
    rs.close
    set rs = nothing
    con.close
    set con = nothing
    %>

    Il problema è la SQL che dovrebbe buttare dentro i dati nel database di car...
    ma non capisco perchè mi da quell'errore

  4. #4
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Stai provando in remoto o sul tuo pc?
    Non hai i permssi di scrittura per lo user_nomemacchina con il quale effettui le operazioni.

    Roby

  5. #5
    Utente di HTML.it
    Registrato dal
    Sep 2004
    Messaggi
    1,344
    In remoto su un server win 2003 server però ho condiviso la cartella e ho dato tutti i permessi sia anche in scrittura!

  6. #6
    Utente di HTML.it
    Registrato dal
    Sep 2004
    Messaggi
    1,344
    Cavolo! Sei un grande... mi hai risolto in 30 secondi... era proprio perchè nella cartella del databse non avevo il permesso in scrittura...

    Thank You

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.