Oppure

Loading
22/02/10 11:03
Fasyrio
Ciao a tutti ho un problema con questo errore di compilazione, pare che l'istruziona SQL contenga troppi campi. Potreste gentilmente aiutarmi a risolvere questo problema postadomi il codice corretto sia per l'insert che per l'update?
Premetto che uso Visual Basic 6 con un archivi access .mdb, vi incollo l'intera istruzione.
Grazie mille per la collaborazione!

Codice:

If cmbseleziona.Text = "" Then
SQL = "INSERT INTO utenti " _
& "(nome, cognome, indirizzo, mansione, data_nascita, liv_cat, data_assunzione,citta, provincia, titolo_studio, telefono, diplomi, esperienze, check1, check2, check3, check4, check5, check6, check7, check8, check9, check10) " _
& "VALUES " _
& "('" & Replace(txtnome.Text, "'", "''";) & "', " _
& "'" & Replace(txtcognome.Text, "'", "''";) & "', " _
& "'" & Replace(txtindirizzo.Text, "'", "''";) & "', " _
& "'" & Replace(txtmansione.Text, "'", "''";) & "', " _
& "'" & Replace(txtdata_nascita.Text, "'", "''";) & "', " _
& "'" & Replace(txtliv_cat.Text, "'", "''";) & "', " _
& "'" & Replace(txtdata_assunzione.Text, "'", "''";) & "', " _
& "'" & Replace(txtcitta.Text, "'", "''";) & "', " _
& "'" & Replace(txtprovincia.Text, "'", "''";) & "', " _
& "'" & Replace(txttitolo_studio.Text, "'", "''";) & "', " _
& "'" & Replace(txttelefono.Text, "'", "''";) & "', " _
& "'" & Replace(txtdiplomi.Text, "'", "''";) & "', " _
& "'" & Replace(txtesperienze.Text, "'", "''";) & "', " _
& "'" & Replace(txtcheck1.Text, "'", "''";) & "', " _
& "'" & Replace(txtcheck2.Text, "'", "''";) & "', " _
& "'" & Replace(txtcheck3.Text, "'", "''";) & "', " _
& "'" & Replace(txtcheck4.Text, "'", "''";) & "', " _
& "'" & Replace(txtcheck5.Text, "'", "''";) & "', " _
& "'" & Replace(txtcheck6.Text, "'", "''";) & "', " _
& "'" & Replace(txtcheck7.Text, "'", "''";) & "', " _
& "'" & Replace(txtcheck8.Text, "'", "''";) & "', " _
& "'" & Replace(txtcheck9.Text, "'", "''";) & "', "
& "'" & Replace(txtcheck10.Text, "'", "''";) & "')"
MsgBox "Inserimento Effettuato con successo", 64, "Info"
Else
SQL = "UPDATE utenti SET " _
& "nome = '" & Replace(txtnome.Text, "'", "''";) & "', " _
& "cognome = '" & Replace(txtcognome.Text, "'", "''";) & "', " _
& "indirizzo = '" & Replace(txtindirizzo.Text, "'", "''";) & "', " _
& "mansione = '" & Replace(txtmansione.Text, "'", "''";) & "', " _
& "data_nascita = '" & Replace(txtdata_nascita.Text, "'", "''";) & "', " _
& "liv_cat = '" & Replace(txtliv_cat.Text, "'", "''";) & "', " _
& "data_assunzione = '" & Replace(txtdata_assunzione.Text, "'", "''";) & "', " _
& "citta = '" & Replace(txtcitta.Text, "'", "''";) & "', " _
& "provincia = '" & Replace(txtprovincia.Text, "'", "''";) & "', " _
& "titolo_studio = '" & Replace(txttitolo_studio.Text, "'", "''";) & "', " _
& "telefono = '" & Replace(txttelefono.Text, "'", "''";) & "', " _
& "diplomi = '" & Replace(txtdiplomi.Text, "'", "''";) & "', " _
& "esperienze = '" & Replace(txtesperienze.Text, "'", "''";) & "', " _
& "check1 = '" & Replace(txtcheck1.Text, "'", "''";) & "', " _
& "check2 = '" & Replace(txtcheck2.Text, "'", "''";) & "', " _
& "check3 = '" & Replace(txtcheck3.Text, "'", "''";) & "', " _
& "check4 = '" & Replace(txtcheck4.Text, "'", "''";) & "', " _
& "check5 = '" & Replace(txtcheck5.Text, "'", "''";) & "', " _
& "check6 = '" & Replace(txtcheck6.Text, "'", "''";) & "', " _
& "check7 = '" & Replace(txtcheck7.Text, "'", "''";) & "', " _
& "check8 = '" & Replace(txtcheck8.Text, "'", "''";) & "' " _
& "check9 = '" & Replace(txtcheck9.Text, "'", "''";) & "' " _
& "check10 = '" & Replace(txtcheck10.Text, "'", "''";) & "' " _
& "WHERE id = " & CInt(s(0))
MsgBox "Modifica effettuata con successo", 64, "Info"
End If
aaa
22/02/10 15:45
Alfonso
Mi sembra che sia solo la parte dell'insert che dà problemi.
Potresti incominciare togliendo un po' di concatenazioni.
& "VALUES " _
& "('" & Replace(txtnome.Text, "'", "''") & "', " _
& "'" & Replace(txtcognome.Text, "'", "''") & "', " _
& "'" & Replace(txtindirizzo.Text, "'", "''") & "', " _ 

Diventa
& "VALUES (" _
& Replace(txtnome.Text, "'", "''") & "', '" _
& Replace(txtcognome.Text, "'", "''") & "', '" _
& Replace(txtindirizzo.Text, "'", "''") & "', '" _ 

e così via
aaa
22/02/10 15:51
GrG
come dice anche l'errore stesso secondo me hai messo troppi "accapo" nel codice, intendo troppi:
codice _
& codice _
& ...

cerca di levare un pò di "continuazioni" mettendo più codice per ogni riga
aaa
22/02/10 19:22
nessuno
Modifica questa così

& "(nome, cognome, indirizzo, mansione, data_nascita, liv_cat, data_assunzione,citta, provincia, titolo_studio, telefono, diplomi, esperienze, check1, check2, check3, check4, check5, check6, check7, check8, check9, check10) VALUES " _

e aggiungi il _ in

& "'" & Replace(txtcheck9.Text, "'", "''";) & "', " _

P.S. Ma vedo che hai già ottenuto aiuto in forum.masterdrive.it/visual-basic-6-17/errore-vb6-too-many-long-continuations-44579/
Ultima modifica effettuata da nessuno 22/02/10 19:38
Ricorda che nessuno è obbligato a risponderti e che nessuno è perfetto ...
---
Il grande studioso italiano Bruno de Finetti ( uno dei padri fondatori del moderno Calcolo delle probabilità ) chiamava il gioco del Lotto Tassa sulla stupidità.
25/02/10 8:13
Fasyrio
Grazie mille per l'aiuto!
aaa