Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di Mizushi
    Registrato dal
    Aug 2005
    Messaggi
    1,125

    Array e split di stringa

    Ciao a tutti; utilizzo il seguente codice ASP per eseguire l'upload (Baol) di files su un server remoto e memorizzo alcuni dati in una tabella mysql:

    codice:
    If Request("Upload") = "1" then
    
    Dim oUpload
    
       Set oUpload= new cUpload
       With oUpload
       .EnabledAspUpload = False
       .EnabledLog = False
       .AutoRename = True
       .Overwrite = False
       .SetPath "ticket\"
       .Load 
    
    While Not .Eof
    
     .Save
     
    file_uploaded = replace(oUpload.files("name"), "'", "''") & "." & oUpload.files("ext")
    
    arrNota = Split(oUpload.Form("NOTA"), ", ")
    
    strSQL = " INSERT INTO "
    strSql = strSql & " tbl_ticket "
    strSql = strSql & " ( Note ) "
    strSql = strSql & "   VALUES "
    strSql = strSql & " ( '" & arrNota(i) & "' ) "
    cn.execute strSQL
    
    response.write strSQL &"
    
    "
    
    .MoveNext
    Wend
    
    End With
    Set oUpload = Nothing
    
    end if
    Il problema è che dal form arriva dai diversi campi NOTE una stringa del tipo:

    testo1, testo2
    Che vorrei memorizzare singolarmente sulla tabella; ho splittato per virgola il campo NOTE, ma nella tabella mi registra sempre e soltanto testo1... perchè ?

    Grazie

  2. #2
    Utente di HTML.it L'avatar di Mizushi
    Registrato dal
    Aug 2005
    Messaggi
    1,125
    Soluzione:

    codice:
    If Request("Upload") = "1" then
    
    Dim oUpload
    
       Set oUpload= new cUpload
       With oUpload
       .EnabledAspUpload = False
       .EnabledLog = False
       .AutoRename = True
       .Overwrite = False
       .SetPath "ticket\"
       .Load 
    
    While Not .Eof
    
    arrNota = Split(oUpload.Form("NOTA"), ", ")
    
    for i = LBound(arrNota) to UBound(arrNota)
    
     .Save
     
    file_uploaded = replace(oUpload.files("name"), "'", "''") & "." & oUpload.files("ext")
    
    strSQL = " INSERT INTO "
    strSql = strSql & " tbl_ticket "
    strSql = strSql & " ( Note ) "
    strSql = strSql & "   VALUES "
    strSql = strSql & " ( '" & arrNota(i) & "' ) "
    cn.execute strSQL
    
    response.write strSQL &"
    
    "
    
    .MoveNext
    
    next
    
    Wend
    
    End With
    Set oUpload = Nothing

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 © 2026 vBulletin Solutions, Inc. All rights reserved.