Well I'm very new to SQLite but shouldn't:
UPDATE table SET Value=12.3 WHERE Address=7 and Port=1
be:
UPDATE table SET Value='12.3' WHERE Address='7' and Port='1';
sqlite3_vmprintf() is the recommended method to build SQL with
parameters.
Saturday, March 1, 2008, 6:31:50 PM, you wrote:
tti> The code is very long, I'll try to put here the core of my application.
tti> I'm using a C++ Class where one function is "sqlraw" that I use to
tti> execute a SQL statement:
tti> CLASS DEFINITION
tti> sqlite3 *db;
tti> int expander::
tti> open_db(char * pDbName)
tti> {
tti> int rc;
tti> rc = sqlite3_open(pDbName, &db);
tti> if( rc )
tti> {
tti> fprintf(stderr, "Can't open database: %s\n",
tti> sqlite3_errmsg(db));
tti> sqlite3_close(db);
tti> exit(1);
tti> }
tti> return(0);
tti> }
tti> int expander::sqlraw(char *pSql)
tti> {
tti> int rc;
tti> char *zErrMsg = 0;
tti> printf("SQLRAW: SQL=%s\n",pSql);
tti> printf("Database %d\n",db);
tti> rc =
tti> sqlite3_exec(db,pSql, NULL, NULL, &zErrMsg );
tti> printf("SQLRAW: Stato=%d
tti> - OK=%d\n",rc, SQLITE_OK);
tti> if( rc!=SQLITE_OK )
tti> {
tti> fprintf(stderr,
tti> "SQL error: %s\n", zErrMsg);
tti> sqlite3_free(zErrMsg);
tti> return(-1);
tti> }
tti> return(0);
tti> }
tti> int main(int argc ,char *argv[])
tti> {
tti> expander expio;
tti> char sPre[2048[;
tti> expio.open("test.db");
tti> strcpy(sPre,"UPDATE
tti> table SET Value=12.3 WHERE Address=7 and Port=1");
tti> if (expio.sqlraw
tti> (sPre) == 0)
tti> {
tti> / / Action for no error
tti> }
tti> else
tti> {
tti> // Manage error conditions
tti> }
tti> When I execute the code, sqlraw
tti> function print the pSql string, and this is the same I pass.
tti> The
tti> Database descriptor is the same returned from open function, and status
tti> code is OK!!!
tti> But table value isn't updated.
tti> I don't understand
tti> what's matter, and because i haven't any error message I can't debug
tti> it.
tti> Any suggestion is VERY VERY appreciate
tti> Pierluigi Bucolo
--
Best regards,
Neville Franks, http://www.surfulater.com http://blog.surfulater.com
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users