Visualizzazione dei risultati da 1 a 10 su 10

Discussione: xml & database

  1. #1
    Utente di HTML.it L'avatar di jartuf
    Registrato dal
    Oct 2002
    Messaggi
    174

    xml & database

    Ciao a tutti,
    ho la seguente pag xml
    codice:
    <news data="30/05/2002">Aggiornamento della sezione DownLoad.</news>
    che viene caricata in un box flash. Vorrei che i valori venissero caricati da Database che aggiorno in asp, come faccio a recuperarli??

    grazie
    La vita è una scala. Non smettere mai di salire.
    Jartuf Art Design
    La Web-tv degli studenti di Bologna

  2. #2
    Forse non ho capito bene il problema. Vorresti prelevare dei dati da database e passarli in una pagina xml che poi viene caricata in un box flash?

  3. #3
    Utente di HTML.it L'avatar di jartuf
    Registrato dal
    Oct 2002
    Messaggi
    174
    be praticamente si!
    lo so che forse è paradossale, ma
    1- con asp me la cavo ad interagire co db
    2- il box flash che ho preso da enricolai.com carica da xml
    3- vorrei imparare qlc in xml


    si puo fare? penso di si...io ancora nn ci sono riuscito
    La vita è una scala. Non smettere mai di salire.
    Jartuf Art Design
    La Web-tv degli studenti di Bologna

  4. #4
    Allora prova con questo:
    codice:
    <html>
    <title>CodeAve.com(Create XML from Access)</title>
    <body bgcolor="#FFFFFF">
    <%
    ' Name of the access db being queried
    accessdb="tuo_database" 
    
    ' Connection string to the access db
    cn="DRIVER={Microsoft Access Driver (*.mdb)};"
    cn=cn & "DBQ=" & server.mappath(accessdb)
    
    ' Create a server recordset object
    Set rs = Server.CreateObject("ADODB.Recordset")
    
    ' Query the states table from the tuo_database db
    sql = "select state,statename,capital,year,order from states order by states.order " 
    
    ' Execute the sql
    rs.Open sql, cn
    
    ' Move to the first record
    rs.MoveFirst
    
    ' Name for the ouput document 
    file_being_created= "states.xml"
    
    ' create a file system object
    set fso = createobject("scripting.filesystemobject")
    
    ' create the text file  - true will overwrite any previous files
    ' Writes the db output to a .xml file in the same directory 
    Set act = fso.CreateTextFile(server.mappath(file_being_created), true)
    
    ' All non repetitive xml on top goes here
    act.WriteLine("<?xml version=""1.0""?>")
    act.WriteLine("<states>")
    
    'Loop to output all the query results to the xml document
    do while not rs.eof
    
    ' counter to give each record a sequential listing
    counter=counter+1
    
    act.WriteLine("<state id="""& counter &""">")
    act.WriteLine("<state_abbrev>" & rs("state") & "</state_abbrev>" )
    act.WriteLine("<state_name>" & rs("statename") & "</state_name>" )
    act.WriteLine("<state_capital>" & rs("capital") & "</state_capital>")
    act.WriteLine("<year_admitted>"& rs("year") & "</year_admitted>")
    act.WriteLine("<order_admitted>"& rs("order") & "</order_admitted>")
    act.WriteLine("</state>")
    
    ' move to the next record
    rs.movenext
    loop
    
    ' All non repetitive xml on bottom goes here
    act.WriteLine("</states>")
    
    
    ' close the object (xml)
    act.close
    
    
    ' Writes a link to the newly created xml document in the browser
    response.write "States (.xml) has been created 
    "
    response.write "on  " & now() & "
    "
    %>
    </body>
    </html>
    questo script preleva i dati da un database e li salva in un file xml e lo chiama "states.xml"

  5. #5
    Utente di HTML.it L'avatar di jartuf
    Registrato dal
    Oct 2002
    Messaggi
    174
    ok, funge ora lo sto modificando graziE!
    l'unico problema è
    codice:
    Tipo di errore:
    Errore di run-time di Microsoft VBScript (0x800A0046)
    Autorizzazione negata
    /pannello/box_news/salva_file.asp, line 32
    e credo che nn riesca a sovrascrivere un file già fatto, sai perchè e come risolvere? grazie cmq, ciao!
    La vita è una scala. Non smettere mai di salire.
    Jartuf Art Design
    La Web-tv degli studenti di Bologna

  6. #6
    Utente di HTML.it L'avatar di jartuf
    Registrato dal
    Oct 2002
    Messaggi
    174
    no no, tutto ok ora va alla grande!

    ho un ultimo step: ho un loop, posso però bloccare questo ad un max di 4 risultati?
    Cioè, voglio scrivere nell'xml solo gli ultimi 4 record

    grAZIE
    La vita è una scala. Non smettere mai di salire.
    Jartuf Art Design
    La Web-tv degli studenti di Bologna

  7. #7
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Usi un contatore e quando vale 4 esci dal Loop.

    Roby

  8. #8
    Utente di HTML.it L'avatar di jartuf
    Registrato dal
    Oct 2002
    Messaggi
    174
    mi ero incasinato da solo con i 4 campi, invece piu semplicamente ho fatto
    codice:
    sql = "select top 4 * from news "
    solo che leggo che potrebbe prendere + campi in caso di aexequo...
    il contatore? umh...mai sentito, provo a fare una ricerca.
    La vita è una scala. Non smettere mai di salire.
    Jartuf Art Design
    La Web-tv degli studenti di Bologna

  9. #9
    Utente di HTML.it
    Registrato dal
    Apr 2007
    Messaggi
    6
    Originariamente inviato da jartuf
    be praticamente si!
    lo so che forse è paradossale, ma
    1- con asp me la cavo ad interagire co db
    2- il box flash che ho preso da enricolai.com carica da xml
    3- vorrei imparare qlc in xml


    si puo fare? penso di si...io ancora nn ci sono riuscito
    Mi è capitato oggi di aver bisogno di una cosa del genere e dopo aver letto attentamente ho opportunamente modificato con i miei dati quanto già successo a jartuf ovvero

    Microsoft VBScript runtime error '800a0046'

    Permission denied

    /newsrss.asp, line 32 .

    Non conosco bene ASP ma mi pare di capire che lui alla fine dell'estrazione crea il file XML con i dati estratti nella stessa directory del database, cosa che io vorrei evitare ma vorrei salvarlo nella root directory ma non so come fare.

    Mi postresti dare una mano ?



    P:S:
    ecco il listato modoficato da me:
    <html>
    <title>CodeAve.com(Create XML from Access)</title>
    <body bgcolor="#FFFFFF">
    <%
    ' Name of the access db being queried
    accessdb="/mdb-database/Quicknews.mdb"

    ' Connection string to the access db
    cn="DRIVER={Microsoft Access Driver (*.mdb)};"
    cn=cn & "DBQ=" & server.mappath(accessdb)

    ' Create a server recordset object
    Set rs = Server.CreateObject("ADODB.Recordset")

    ' Query the states table from the tuo_database db
    sql = "select ArticleID,ArticleName from tblQNArticles ORDER BY ArticleID DESC"

    ' Execute the sql
    rs.Open sql, cn

    ' Move to the first record
    rs.MoveFirst

    ' Name for the ouput document
    file_being_created= "rssnews.xml"

    ' create a file system object
    set fso = createobject("scripting.filesystemobject")

    ' create the text file - true will overwrite any previous files
    ' Writes the db output to a .xml file in the same directory
    Set act = fso.CreateTextFile(server.mappath(file_being_creat ed), true)

    ' All non repetitive xml on top goes here
    act.WriteLine("<?xml version=""1.0""?>")
    act.WriteLine("<states>")

    'Loop to output all the query results to the xml document
    do while not rs.eof

    ' counter to give each record a sequential listing
    counter=counter+1

    act.WriteLine("<state id="""& counter &""">")
    act.WriteLine("<state_id>" & rs("ArticleID") & "</state_id>")
    act.WriteLine("<state_name>" & rs("ArticleName") & "</state_name>" )
    act.WriteLine("<state_data>" & rs("ArticleData") & "</state_id>")
    act.WriteLine("</state>")

    ' move to the next record
    rs.movenext
    loop

    ' All non repetitive xml on bottom goes here
    act.WriteLine("</states>")


    ' close the object (xml)
    act.close


    ' Writes a link to the newly created xml document in the browser
    response.write "RSS feed (.xml) has been created
    "
    response.write "on " & now() & "
    "
    %>
    </body>
    </html>

  10. #10
    Utente di HTML.it
    Registrato dal
    Apr 2007
    Messaggi
    6
    Risolto da solo.


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.