I've been trying at this for a good few hours now, I'm using sqlite3 and the quick start code at the website.

By using a global "char *buffer[5][220];"
and then doing buffer[i][counter]=argv[i]; I thought I would be able to extract the rows in my table but it does not work. When the program has exited the callback buffer[i][0] equals buffer[i][1] and so on. For some reason all of them will have the values of the last callback execution.


int counter=0;
char *buffer[5][220];
int rows;

static int callback(void *NotUsed, int argc, char **argv, char **azColName){
   int k;
   rows=argc;
   for(k=0;k<argc;k++)
   {
       buffer[k][counter]= argv[k];
   }
   counter++;
   return 0;
}

 rc = sqlite3_exec(db, "SELECT * FROM gg", callback, 0, &zErrMsg);
 int i,p;
 for(i=0;i<counter;i++)
 {
     for(p=0;p<rows;p++)
     {
         cout << i << buffer[p][i] << "\t";
     }
     cout << endl;
 }

gg in this case holds:
Name   Shirt
Aleks    10
Milla      4

my program returns:
Milla 4
Milla 4


(this is just an extract of the code off course) I hope you understand my problem and can help me solve it...

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now! http://toolbar.msn.com/




Reply via email to