Well, I'm no C programmer, so I might be full of crap, but it looks like you're 
closing the db connection inside your while block (after you get the first 
row's data).  Not sure about the exact usage for reset() and finalize(), but 
they don't seem proper inside a loop like yours.  Last, it looks like you skip 
every odd row by calling step(oStmt) in the while condition, and then again 
inside the block.

 -Clark

----- Original Message ----
From: Severin Müller <[EMAIL PROTECTED]>
To: sqlite-users@sqlite.org
Sent: Tuesday, March 25, 2008 2:14:33 PM
Subject: [sqlite] [C] Getting results doesn't work properly

Hi Folks

I have the following C funtion:

void get_acc(char *src,int ac,char **av)
{
       char *buf = "SELECT accmask FROM testtable;");
    sqlite3 *db;
    struct sqlite3_stmt *oStmt;
        int rc;    
    if(sqlite3_prepare_v2(db,buf,strlen(buf),&oStmt,NULL)==SQLITE_OK)
    {
        while(sqlite3_step(oStmt)==SQLITE_ROW)
        {
            sqlite3_step(oStmt);
            txt = (char*)sqlite3_column_text(oStmt,0);
            sqlite3_reset(oStmt);
            sqlite3_finalize(oStmt);
                        sqlite3_close(db);
            printf("Result: %s\n",txt);
        }
    }
 }

If i call the function, only one row is returned, but there are definately more 
(i check with SELECT COUNT(*)). Did i oversee something? Or what's wrong here?

Thanks again for your help.

Kind regards

Severin
-- 



Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger
_______________________________________________
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

Reply via email to