faustf Posted June 12, 2015 Share Posted June 12, 2015 hi guy i have program it must insert in db a simple 8 item name mail etc etci do a script like thisFunc _inserisci_anagrafica() $nome_ana = GUICtrlRead($input9) $mail_ana = GUICtrlRead($Input10) $tele_ana = GUICtrlRead($Input11) $comune_ana = GUICtrlRead($Input12) $indi_ana = GUICtrlRead($Input14) $passw_ana = GUICtrlRead($Input13) $paypal_ana = GUICtrlRead($Input15) SQLITE_APERTURA() ; con questa funzione facciopartire sql e apro il db robo_annunci nella script dir If Not _SQLite_Exec(-1, "INSERT INTO configurazione(nome,email,telefono,comune,indirizzo,password,paypal) VALUES ('" & $nome_ana & "','" & $mail_ana & "''" & $tele_ana & "','" & $comune_ana & "''" & $indi_ana & "','" & $passw_ana & "''" & $paypal_ana & "');") = $SQLITE_OK Then _ MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg()) SQLITE_CHIUSURA() ; con questa funzione chiudo il database e shutdown lsqlite EndFunc ;==>_inserisci_anagraficabut it give me this error Query: INSERT INTO configurazione(nome,email,telefono,comune,indirizzo,password,paypal) VALUES ('Input9','Input10''Input11','Input12''Input14','Input13''Input15');--> Error: 4 values for 7 columnssome one could help me thankzat all Link to comment Share on other sites More sharing options...
abberration Posted June 12, 2015 Share Posted June 12, 2015 I think the error may have to do with the quotes. Can you post an example of what the SQL string should look like outside of AutoIt? We need to see what needs a hard quote around it and how the commas should look. Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
jchd Posted June 12, 2015 Share Posted June 12, 2015 (edited) faustf,You're missing three commas between values. Note that your statement would also fail if ever a single quote is part of one of the string entered in the GUI.This should work better:Func _inserisci_anagrafica() $nome_ana = GUICtrlRead($input9) $mail_ana = GUICtrlRead($Input10) $tele_ana = GUICtrlRead($Input11) $comune_ana = GUICtrlRead($Input12) $indi_ana = GUICtrlRead($Input14) $passw_ana = GUICtrlRead($Input13) $paypal_ana = GUICtrlRead($Input15) SQLITE_APERTURA() ; con questa funzione facciopartire sql e apro il db robo_annunci nella script dir ;~ If Not _SQLite_Exec(-1, "INSERT INTO configurazione(nome,email,telefono,comune,indirizzo,password,paypal) VALUES ('" & $nome_ana & "','" & $mail_ana & "','" & $tele_ana & "','" & $comune_ana & "','" & $indi_ana & "','" & $passw_ana & "','" & $paypal_ana & "');") = $SQLITE_OK Then _ ;~ MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg()) ; ======= prefer this If Not _SQLite_Exec(-1, "INSERT INTO configurazione (" & _ "nome," & _ "email," & _ "telefono," & _ "comune," & _ "indirizzo," & _ "password," & _ "paypal) " & _ "VALUES (" & _ _SQLite_FastEscape($nome_ana) & "," & _ _SQLite_FastEscape($mail_ana) & "," & _ _SQLite_FastEscape($tele_ana) & "," & _ _SQLite_FastEscape($comune_ana) & "," & _ _SQLite_FastEscape($indi_ana) & "," & _ _SQLite_FastEscape($passw_ana) & "," & _ _SQLite_FastEscape($paypal_ana) & _ ");") = $SQLITE_OK Then _ MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg()) SQLITE_CHIUSURA() ; con questa funzione chiudo il database e shutdown lsqlite EndFunc ;==>_inserisci_anagraficaThere is no need to open and close the DB at every statement. Typically code should be like that:... _SQLite_Startup() Local $hDB $hDB = _SQLite_Open($sDbName) ... all of DB operations spread in various functions _SQLite_Close($hDB) _SQLite_Shutdown()One last thing: writing If Not _SQlite_Exec( ... ) = _$SQLITE_OK should be: If _SQlite_Exec( ... ) <> _$SQLITE_OK Edited June 12, 2015 by jchd faustf 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
faustf Posted June 12, 2015 Author Share Posted June 12, 2015 thankz so much jchd and vertical structure is best also for me thankz so much Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now