Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 11
  1. #1

    Esportare campo memo access in file CSV

    Salve a tutti,

    esporto tramite file csv i dati di una tabella.
    Il separatore è una virgola.
    Ho un problema con i campo di tipo memo. in quanto non me lo scrive nel file csv.

    Da cosa può dipendere?

    Grazie a tutti in anticipo
    <a href="http://www.robertodidonato.it" target="_blank">Roberto Di Donato</a>

  2. #2
    Moderatore di JavaScript L'avatar di br1
    Registrato dal
    Jul 1999
    Messaggi
    19,998
    Il tuo codice?
    Il guaio per i poveri computers e' che sono gli uomini a comandarli.

    Attenzione ai titoli delle discussioni: (ri)leggete il regolamento
    Consultate la discussione in rilievo: script / discussioni utili
    Usate la funzione di Ricerca del Forum

  3. #3
    Hai ragione scusa:
    codice:
    <%
     'Response.ContentType = "application/msexcel"
     'INTESTAZIONE
     strXls = chr(34) & "Titolo" & chr(34) & ","
     strXls = strXls & chr(34) & "Titolo straniero" & chr(34) & ","
     strXls = strXls & chr(34) & "Nome" & chr(34) & ","
     strXls = strXls & chr(34) & "Secondo nome" & chr(34) & ","
     strXls = strXls & chr(34) & "Cognome" & chr(34) & ","
     strXls = strXls & chr(34) & "Categoria" & chr(34) & ","
     strXls = strXls & chr(34) & "Compleanno" & chr(34) & ","
     strXls = strXls & chr(34) & "Indirizzo posta elettronica" & chr(34) & ","
     strXls = strXls & chr(34) & "Pagina Web" & chr(34) & ","
     strXls = strXls & chr(34) & "Nome coniuge" & chr(34) & ","
     strXls = strXls & chr(34) & "Notes" & chr(34) & ","
     strXls = strXls & chr(34) & "Società" & chr(34) & ","
     strXls = strXls & chr(34) & "Posizione" & chr(34) & ","
     strXls = strXls & chr(34) & "Nome assistente" & chr(34) & ","
     strXls = strXls & chr(34) & "Riservatezza" & chr(34) & ","
     strXls = strXls & chr(34) & "Ufficio" & chr(34) & ","
     strXls = strXls & chr(34) & "Ufficio 2" & chr(34) & ","
     strXls = strXls & chr(34) & "Fax (uff.)" & chr(34) & ","
     strXls = strXls & chr(34) & "Abitazione" & chr(34) & ","
     strXls = strXls & chr(34) & "Abitazione 2" & chr(34) & ","
     strXls = strXls & chr(34) & "Cellulare" & chr(34) & ","
     strXls = strXls & chr(34) & "Altro telefono" & chr(34) & ","
     strXls = strXls & chr(34) & "Fax (ab.)" & chr(34) & ","
     strXls = strXls & chr(34) & "Paese (uff.)" & chr(34) & ","
     strXls = strXls & chr(34) & "Via (uff.)" & chr(34) & ","
     strXls = strXls & chr(34) & "CAP (uff.)" & chr(34) & ","
     strXls = strXls & chr(34) & "Città (uff.)" & chr(34) & ","
     strXls = strXls & chr(34) & "Provincia (uff.)" & chr(34) & ","
     strXls = strXls & chr(34) & "Paese (ab.)" & chr(34) & ","
     strXls = strXls & chr(34) & "Via (ab.)" & chr(34) & ","
     strXls = strXls & chr(34) & "CAP (ab.)" & chr(34) & ","
     strXls = strXls & chr(34) & "Città (ab.)" & chr(34) & ","
     strXls = strXls & chr(34) & "Provincia (ab.)" & chr(34) & "," & VbCrlf
     Set conn = Server.CreateObject("ADODB.Connection")
    sql = "SELECT noteUtente, titolo, titoloStraniero, Nome, secondoNome, cognome, visualizzaCome, categoria, dataNascita, mailUtente, indirizzoWeb, coniuge, societa, posizione, assistente, riservato, telefonoUfficio, telefonoUfficio_2, faxUfficio, telefonoAbitazione, telefonoAbitazione_2, cellulare, cellulare_2, faxAbitazione, nazioneUfficio, viaUfficio, capUfficio, cittaUfficio, provinciaUfficio, nazioneAbitazione, viaAbitazione, capAbitazione, cittaAbitazione, provinciaAbitazione FROM tb_contatti"
     dsnpath = "DRIVER={MICROSOFT ACCESS DRIVER (*.mdb)}; "
     dsnpath = dsnpath & "DBQ=" & Server.MapPath("mdb-database/albDc_contatti.mdb")
     conn.open dsnpath
     Set rs = Server.CreateObject("ADODB.Recordset")
     Set Rs=Conn.Execute(SQL)
     Do Until RS.EOF
     'if rs("noteUtente") <> "" Then
     'noteUtente = rs("noteUtente")
     'noteUtenteDef= Replace(noteUtente, VbCrLf, "<BR>")
     'else
     'noteUtente = ""
     'End if
     strXls = strXls & chr(34) & rs("titolo") & chr(34) & ","
     strXls = strXls & chr(34) & rs("titoloStraniero") & chr(34) & ","
     strXls = strXls & chr(34) & rs("Nome") & chr(34) & ","
     strXls = strXls & chr(34) & rs("secondoNome") & chr(34) & ","
     strXls = strXls & chr(34) & rs("cognome") & chr(34) & ","
     strXls = strXls & chr(34) & rs("categoria") & chr(34) & ","
     strXls = strXls & chr(34) & rs("dataNascita") & chr(34) & ","
     strXls = strXls & chr(34) & rs("mailUtente") & chr(34) & ","
     strXls = strXls & chr(34) & rs("indirizzoWeb") & chr(34) & ","
     strXls = strXls & chr(34) & rs("coniuge") & chr(34) & ","
     if rs("noteUtente") <> "" Then
     strXls = strXls & chr(34) & "Pieno" & rs("noteUtente") & chr(34) & ","
     else
     strXls = strXls & chr(34) & "Vuoto" & chr(34) & ","
     End if
     strXls = strXls & chr(34) & rs("societa") & chr(34) & ","
     strXls = strXls & chr(34) & rs("posizione") & chr(34) & ","
     strXls = strXls & chr(34) & rs("assistente") & chr(34) & ","
     strXls = strXls & chr(34) & rs("riservato") & chr(34) & ","
     strXls = strXls & chr(34) & rs("telefonoUfficio") & chr(34) & ","
     strXls = strXls & chr(34) & rs("telefonoUfficio_2") & chr(34) & ","
     strXls = strXls & chr(34) & rs("faxUfficio") & chr(34) & ","
     strXls = strXls & chr(34) & rs("telefonoAbitazione") & chr(34) & ","
     strXls = strXls & chr(34) & rs("telefonoAbitazione_2") & chr(34) & ","
     strXls = strXls & chr(34) & rs("cellulare") & chr(34) & ","
     strXls = strXls & chr(34) & rs("cellulare_2") & chr(34) & ","
     strXls = strXls & chr(34) & rs("faxAbitazione") & chr(34) & ","
     strXls = strXls & chr(34) & rs("nazioneUfficio") & chr(34) & ","
     strXls = strXls & chr(34) & rs("viaUfficio") & chr(34) & ","
     strXls = strXls & chr(34) & rs("capUfficio") & chr(34) & ","
     strXls = strXls & chr(34) & rs("cittaUfficio") & chr(34) & ","
     strXls = strXls & chr(34) & rs("provinciaUfficio") & chr(34) & ","
     strXls = strXls & chr(34) & rs("nazioneAbitazione") & chr(34) & ","
     strXls = strXls & chr(34) & rs("viaAbitazione") & chr(34) & ","
     strXls = strXls & chr(34) & rs("capAbitazione") & chr(34) & ","
     strXls = strXls & chr(34) & rs("cittaAbitazione") & chr(34) & ","
     strXls = strXls & chr(34) & rs("provinciaAbitazione") & chr(34) & "," & VbCrlf
     
     rs.MoveNext
     loop
    Response.Write(strXls)
     set rs = Nothing
     conn.Close
     Set conn = Nothing
     
     'FileName="contatti_outlook.csv" 'default file name
     'Response.Clear
     'Response.ContentType = "text/csv"
     'Response.AddHeader "Content-Disposition", "filename=" & FileName & ";"
     
     %>
    <a href="http://www.robertodidonato.it" target="_blank">Roberto Di Donato</a>

  4. #4
    Aggiornamento. Ho modificato il codice in questa maniera:
    codice:
    <%
     'Response.ContentType = "application/msexcel"
     'INTESTAZIONE
     strXls = chr(34) & "Titolo" & chr(34) & ","
     strXls = strXls & chr(34) & "Titolo straniero" & chr(34) & ","
     strXls = strXls & chr(34) & "Nome" & chr(34) & ","
     strXls = strXls & chr(34) & "Secondo nome" & chr(34) & ","
     strXls = strXls & chr(34) & "Cognome" & chr(34) & ","
     strXls = strXls & chr(34) & "Categoria" & chr(34) & ","
     strXls = strXls & chr(34) & "Compleanno" & chr(34) & ","
     strXls = strXls & chr(34) & "Indirizzo posta elettronica" & chr(34) & ","
     strXls = strXls & chr(34) & "Pagina Web" & chr(34) & ","
     strXls = strXls & chr(34) & "Nome coniuge" & chr(34) & ","
     strXls = strXls & chr(34) & "Notes" & chr(34) & ","
     strXls = strXls & chr(34) & "Società" & chr(34) & ","
     strXls = strXls & chr(34) & "Posizione" & chr(34) & ","
     strXls = strXls & chr(34) & "Nome assistente" & chr(34) & ","
     strXls = strXls & chr(34) & "Riservatezza" & chr(34) & ","
     strXls = strXls & chr(34) & "Ufficio" & chr(34) & ","
     strXls = strXls & chr(34) & "Ufficio 2" & chr(34) & ","
     strXls = strXls & chr(34) & "Fax (uff.)" & chr(34) & ","
     strXls = strXls & chr(34) & "Abitazione" & chr(34) & ","
     strXls = strXls & chr(34) & "Abitazione 2" & chr(34) & ","
     strXls = strXls & chr(34) & "Cellulare" & chr(34) & ","
     strXls = strXls & chr(34) & "Altro telefono" & chr(34) & ","
     strXls = strXls & chr(34) & "Fax (ab.)" & chr(34) & ","
     strXls = strXls & chr(34) & "Paese (uff.)" & chr(34) & ","
     strXls = strXls & chr(34) & "Via (uff.)" & chr(34) & ","
     strXls = strXls & chr(34) & "CAP (uff.)" & chr(34) & ","
     strXls = strXls & chr(34) & "Città (uff.)" & chr(34) & ","
     strXls = strXls & chr(34) & "Provincia (uff.)" & chr(34) & ","
     strXls = strXls & chr(34) & "Paese (ab.)" & chr(34) & ","
     strXls = strXls & chr(34) & "Via (ab.)" & chr(34) & ","
     strXls = strXls & chr(34) & "CAP (ab.)" & chr(34) & ","
     strXls = strXls & chr(34) & "Città (ab.)" & chr(34) & ","
     strXls = strXls & chr(34) & "Provincia (ab.)" & chr(34) & "," & VbCrlf
     Set conn = Server.CreateObject("ADODB.Connection")
    sql = "SELECT titolo, titoloStraniero, Nome, secondoNome, cognome, visualizzaCome, categoria, dataNascita, mailUtente, indirizzoWeb, coniuge, noteUtente, societa, posizione, assistente, riservato, telefonoUfficio, telefonoUfficio_2, faxUfficio, telefonoAbitazione, telefonoAbitazione_2, cellulare, cellulare_2, faxAbitazione, nazioneUfficio, viaUfficio, capUfficio, cittaUfficio, provinciaUfficio, nazioneAbitazione, viaAbitazione, capAbitazione, cittaAbitazione, provinciaAbitazione FROM tb_contatti"
     dsnpath = "DRIVER={MICROSOFT ACCESS DRIVER (*.mdb)}; "
     dsnpath = dsnpath & "DBQ=" & Server.MapPath("mdb-database/albDc_contatti.mdb")
     conn.open dsnpath
     Set rs = Server.CreateObject("ADODB.Recordset")
     Set Rs=Conn.Execute(SQL)
     Do Until RS.EOF
     'if rs("noteUtente") <> "" Then
     'noteUtente = rs("noteUtente")
     'noteUtenteDef= Replace(noteUtente, VbCrLf, "<BR>")
     'else
     'noteUtente = ""
     'End if
     MyString = rs("noteUtente")
    if not (IsNull (MyString) ) then
    MyString = Replace(Replace(MyString, vbCrLf, ""), ",","; ")
    else
    MyString = "Vuoto"
    end if
     strXls = strXls & chr(34) & rs("titolo") & chr(34) & ","
     strXls = strXls & chr(34) & rs("titoloStraniero") & chr(34) & ","
     strXls = strXls & chr(34) & rs("Nome") & chr(34) & ","
     strXls = strXls & chr(34) & rs("secondoNome") & chr(34) & ","
     strXls = strXls & chr(34) & rs("cognome") & chr(34) & ","
     strXls = strXls & chr(34) & rs("categoria") & chr(34) & ","
     strXls = strXls & chr(34) & rs("dataNascita") & chr(34) & ","
     strXls = strXls & chr(34) & rs("mailUtente") & chr(34) & ","
     strXls = strXls & chr(34) & rs("indirizzoWeb") & chr(34) & ","
     strXls = strXls & chr(34) & rs("coniuge") & chr(34) & ","
    ' if MyString <> "" Then
     strXls = strXls & chr(34) & MyString & chr(34) & ","
     'else
     'strXls = strXls & chr(34) & "Vuoto" & chr(34) & ","
     'End if
     strXls = strXls & chr(34) & rs("societa") & chr(34) & ","
     strXls = strXls & chr(34) & rs("posizione") & chr(34) & ","
     strXls = strXls & chr(34) & rs("assistente") & chr(34) & ","
     strXls = strXls & chr(34) & rs("riservato") & chr(34) & ","
     strXls = strXls & chr(34) & rs("telefonoUfficio") & chr(34) & ","
     strXls = strXls & chr(34) & rs("telefonoUfficio_2") & chr(34) & ","
     strXls = strXls & chr(34) & rs("faxUfficio") & chr(34) & ","
     strXls = strXls & chr(34) & rs("telefonoAbitazione") & chr(34) & ","
     strXls = strXls & chr(34) & rs("telefonoAbitazione_2") & chr(34) & ","
     strXls = strXls & chr(34) & rs("cellulare") & chr(34) & ","
     strXls = strXls & chr(34) & rs("cellulare_2") & chr(34) & ","
     strXls = strXls & chr(34) & rs("faxAbitazione") & chr(34) & ","
     strXls = strXls & chr(34) & rs("nazioneUfficio") & chr(34) & ","
     strXls = strXls & chr(34) & rs("viaUfficio") & chr(34) & ","
     strXls = strXls & chr(34) & rs("capUfficio") & chr(34) & ","
     strXls = strXls & chr(34) & rs("cittaUfficio") & chr(34) & ","
     strXls = strXls & chr(34) & rs("provinciaUfficio") & chr(34) & ","
     strXls = strXls & chr(34) & rs("nazioneAbitazione") & chr(34) & ","
     strXls = strXls & chr(34) & rs("viaAbitazione") & chr(34) & ","
     strXls = strXls & chr(34) & rs("capAbitazione") & chr(34) & ","
     strXls = strXls & chr(34) & rs("cittaAbitazione") & chr(34) & ","
     strXls = strXls & chr(34) & rs("provinciaAbitazione") & chr(34) & "," & VbCrlf
     
     rs.MoveNext
     loop
    Response.Write(strXls)
     set rs = Nothing
     conn.Close
     Set conn = Nothing
     
     'FileName="contatti_outlook.csv" 'default file name
     'Response.Clear
     'Response.ContentType = "text/csv"
     'Response.AddHeader "Content-Disposition", "filename=" & FileName & ";"
     
     %>
    Così leggo il campo memo ma si blocca subito dopo lo stesso campo memo nell'estrazione dei dati.
    Ho fatto il replace dell'accapo e delle virgole:
    Questo è il risultato a video:
    "Titolo","Titolo straniero","Nome","Secondo nome","Cognome","Categoria","Compleanno","Indirizz o posta elettronica","Pagina Web","Nome coniuge","Notes","Società ","Posizione","Nome assistente","Riservatezza","Ufficio","Ufficio 2","Fax (uff.)","Abitazione","Abitazione 2","Cellulare","Altro telefono","Fax (ab.)","Paese (uff.)","Via (uff.)","CAP (uff.)","Città (uff.)","Provincia (uff.)","Paese (ab.)","Via (ab.)","CAP (ab.)","Città (ab.)","Provincia (ab.)", "The","","Houston","","Museum of Fine Arts","","","xxxxxx@xxxxxx.org","","","Location address: 1406 Kirby Drive; Houston Texas 77019Office address:5601 Main Street; Houston Texas 77005Mrs Katherine S. HoweCell 713 2899 4453Curator; Decorative Arts MFAH

    Quello in bold è il campo memo. Lo visualizza tutto ma poi si blocca.
    <a href="http://www.robertodidonato.it" target="_blank">Roberto Di Donato</a>

  5. #5
    Ultimo aggiornamento.
    Ho notato che alla fine del testo nel campo memo ci sono degli accapo. Tolti quelli non ci sono problemi.
    Ho provato a modificare la stringa così ma nulla:
    MyStringDef = trim(MyString)

    Epure il replace deglli accampo tra i paragrafi nel campo memo me lo fa.
    <a href="http://www.robertodidonato.it" target="_blank">Roberto Di Donato</a>

  6. #6
    Ho provato a lanciare una query per aggiornare tutti i campi note con il "<br>" al posto del VbCrLf solo che ad un certo punto mi da questo errore:
    Could not save; currently locked by user 'admin' on machine

    Fino a quel punto i record vengono correttamente aggiornati.

    Da cosa dipende questo errore?
    <a href="http://www.robertodidonato.it" target="_blank">Roberto Di Donato</a>

  7. #7
    Ho fatto delle prove e quell'errore me lo da solo se tento di aggiornare il campo memo.
    Se faccio la stessa query su un campo testo normale non mi da problemi.

    Si blocca su una nota molto lunga.

    Se provo ad aggiornare solo quella nota non mi da problemi.
    Messa dentro un ciclo invece mi da errore.

    <a href="http://www.robertodidonato.it" target="_blank">Roberto Di Donato</a>

  8. #8
    Quote Originariamente inviata da bibuz Visualizza il messaggio
    Ho fatto delle prove e quell'errore me lo da solo se tento di aggiornare il campo memo.
    Se faccio la stessa query su un campo testo normale non mi da problemi.

    Si blocca su una nota molto lunga.

    Se provo ad aggiornare solo quella nota non mi da problemi.
    Messa dentro un ciclo invece mi da errore.

    Ho contatto i caratteri della nota incriminata e sono in totale 1475.
    <a href="http://www.robertodidonato.it" target="_blank">Roberto Di Donato</a>

  9. #9
    Risolto grazie.
    Potete chiudere la discussione.
    <a href="http://www.robertodidonato.it" target="_blank">Roberto Di Donato</a>

  10. #10
    Amministratore L'avatar di Vincent.Zeno
    Registrato dal
    May 2003
    residenza
    Emilia-Romagna (tortellini und cappelletti land!)
    Messaggi
    20,812
    Quote Originariamente inviata da bibuz Visualizza il messaggio
    Risolto...
    puoi dirci qual'era il problema e come hai risolto? potrebbe tornare utile ad altri.

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.