Re: [sqlite] Error:"Expression cannot be evaluated" withsqlite3_exec()
On Thu, 16 Oct 2008 08:23:10 + (GMT), Alberto Tellaeche <[EMAIL PROTECTED]> wrote: >int ActualizarBBDDAlumnos(char *dni, float nota) >{ >char *errorMsg; > >char *orden_SQL = sqlite3_mprintf("update ALUMNO set nota=%0.1f where > dni=%Q;",nota,dni); >sqlite3_exec(db,orden_SQL,0,0,); >sqlite3_free(errorMsg); >sqlite3_free(orden_SQL); >return(0); >} "db" appears to be a global. Are you certain that is has been properly initialized with sqlite3_open(), sqlite3_open16() or sqlite3_open_v2() before calling this function? JAB ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Error:"Expression cannot be evaluated"withsqlite3_exec()
"Alberto Tellaeche" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > after sqlite3_mprintf() function, I obtain the string like this: " > update ALUMNO set nota=0.2 where dni='12345678J' " > After sqlite3_exec() errorMsg=NULL (0x Bad ptr), and the > command is not exectuted in table ALUMNO, the value is not changed. How do you know the value has not changed? How do you check it? Do you, by any chance, open a transaction (by executing a BEGIN statement) but don't commit it? If you close the database or exit your application while the transaction is still open, it will roll back. Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Error:"Expression cannot be evaluated" withsqlite3_exec()
Hello Igor; I have modified the code to avoid string writting problems now, it is: int ActualizarBBDDAlumnos(char *dni, float nota) { char *errorMsg; char *orden_SQL = sqlite3_mprintf("update ALUMNO set nota=%0.1f where dni=%Q;",nota,dni); sqlite3_exec(db,orden_SQL,0,0,); sqlite3_free(errorMsg); sqlite3_free(orden_SQL); return(0); } after sqlite3_mprintf() function, I obtain the string like this: " update ALUMNO set nota=0.2 where dni='12345678J' " After sqlite3_exec() errorMsg=NULL (0x Bad ptr), and the command is not exectuted in table ALUMNO, the value is not changed. If I type exactly the same order from the sqlite3 command line, it works perfectly. The database and tables where created folloeing the examples in http://www.sqlite.org/sqlite.html ,with CREATE TABLE commands and INSERT INTO TABLE commands. I still don´t understand what is happening, so, as always, thank you very much. Regards, Alberto - Mensaje original De: Igor Tandetnik <[EMAIL PROTECTED]> Para: sqlite-users@sqlite.org Enviado: miércoles, 15 de octubre, 2008 22:18:48 Asunto: Re: [sqlite] Error:"Expression cannot be evaluated" withsqlite3_exec() Alberto Tellaeche <[EMAIL PROTECTED]> wrote: > Tank you very much for the response. > the array is as expected, sprintf is woking fine. Also I get the same > error if I write the SQL command directly in the sqlite3_exec() > function, so this is not the error... Show the CREATE TABLE statement for ALUMNO table. Show the exact text of the statement you run, after sprintf. Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Error:"Expression cannot be evaluated" withsqlite3_exec()
Alberto Tellaeche <[EMAIL PROTECTED]> wrote: > Tank you very much for the response. > the array is as expected, sprintf is woking fine. Also I get the same > error if I write the SQL command directly in the sqlite3_exec() > function, so this is not the error... Show the CREATE TABLE statement for ALUMNO table. Show the exact text of the statement you run, after sprintf. Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users