Re: [sqlite] Reading error outside the while
John Stanton a écrit : John Stanton wrote: [EMAIL PROTECTED] wrote: John Stanton a écrit : [EMAIL PROTECTED] wrote: Hello, I got an error when I try to read some data outside the while{}, inside the while{} it's ok, an idea ? test.db have just one "table1" and a "field1" with values "one", "two", "three". #include #include int main(void) { sqlite3 *db; sqlite3_stmt *pStat; const char *dbname = "test.db"; const char *sql = "SELECT * FROM table1"; const unsigned char *my_array[3]; int i=0;; sqlite3_open(dbname, &db); sqlite3_prepare_v2(db, sql, -1, &pStat, 0); while(sqlite3_step(pStat) == SQLITE_ROW) { my_array[i] = sqlite3_column_text(pStat, 0); printf ("%s\n",my_array[i]); // ok i++; } for (i = 0; i<3; i++);{ printf ("%s\n", my_array[i]); // error } sqlite3_finalize(pStat); sqlite3_close(db); return 0; } Fred. Your program is wrongly structured. Try this layout: sqlite3_prepare_V2 while (TRUE) { rc = sqlite3_step switch (rc) { case SQLITE_ROW: /*Get each column*/ for (count = 0; count > sqlite3_column_count; count++) { switch (sqlite3_column_type) { case SQLITE_TEXT: pt = sqlite3_column_text /*Move text into your output*/ sprintf(outval, "%s", pt); /*Or some other move.*/ break; case SQLITE_INTEGER: outnbr = sqlite3_column_int; or sprintf(outval, "%d", sqlite_column_int(..)); break; add other types } } break; case SQLITE_DONE: sqlite3_finalize return from function case SQLITE_BUSY: /*Handle BUSY condition.*/ break; default: /*Handle error condition.*/ break; } /*switch*/ } /*while*/ Now you can handle errors, busy conditions and the return of differring types from Sqlite. When you get a pointer to a text value from Sqlite it is the programmer's responsibility to move data from that pointer into data in your program. - To unsubscribe, send email to [EMAIL PROTECTED] - Hello John, Thanks for reply, I just tested with your code that seem to be more useful, but something is wrong : #include #include int main(void) { sqlite3 *db; sqlite3_stmt *pStat; const gchar *dbname = "test.db"; int colcnt; int rc; int finished = 0; rc = sqlite3_open(dbname, &db); if (rc != SQLITE_OK) { printf("error\n"); exit(1); } rc = sqlite3_prepare_v2(db, "SELECT * FROM TABLE1", -1, &pStat, 0); if (rc != SQLITE_OK) { printf("error\n"); exit(1); } while(!finished) { rc = sqlite3_step(pstat); switch (rc) { case SQLITE_ROW: /*Get each column*/ for (colcnt = 0; colcnt < sqlite3_column_count(pStat); colcnt++) { /*Handle returned data according to type.*/ switch (sqlite3_column_type(pStat, 0)) { case SQLITE_TEXT: printf("%s %s ", sqlite3_colimn_name(pstat, colcnt), sqlite3_column_text(pStat,0)); break; case SQLITE_INTEGER: printf("%s %d ", sqlite3_column_name(pstat, colcnt), sqlite3_column_int(pstat); break; /*!!!There are more types like SQLITE_NULL ...*/ } /*switch*/ }/*for*/ printf("\n"); break; case SQLITE_BUSY: /*Busy logic*/ break; case SQLITE_DONE: sqlite3_finalize(pstat); finished = 1; break; default: printf("Error\n"); break; } /*while*/ sqlite3_close(db); exit(0); } You left out quite a bit of the example. I have corrected it, but not tested the code. This should print out a table of what you read. Take note that Sqlite does not have fixed types, so the programmer must be aware of that. You also need to be aware of error conditions and busy states. Whoops, I left out the sqlite3_step. Corrected. - To unsubscribe, send email to [EMAIL PROTECTED] - Works perfectly, thanks you very much. Fred. - To unsubscribe, send email to [EMAIL PROTECTED] --
Re: [sqlite] Reading error outside the while
John Stanton wrote: [EMAIL PROTECTED] wrote: John Stanton a écrit : [EMAIL PROTECTED] wrote: Hello, I got an error when I try to read some data outside the while{}, inside the while{} it's ok, an idea ? test.db have just one "table1" and a "field1" with values "one", "two", "three". #include #include int main(void) { sqlite3 *db; sqlite3_stmt *pStat; const char *dbname = "test.db"; const char *sql = "SELECT * FROM table1"; const unsigned char *my_array[3]; int i=0;; sqlite3_open(dbname, &db); sqlite3_prepare_v2(db, sql, -1, &pStat, 0); while(sqlite3_step(pStat) == SQLITE_ROW) { my_array[i] = sqlite3_column_text(pStat, 0); printf ("%s\n",my_array[i]); // ok i++; } for (i = 0; i<3; i++);{ printf ("%s\n", my_array[i]); // error } sqlite3_finalize(pStat); sqlite3_close(db); return 0; } Fred. Your program is wrongly structured. Try this layout: sqlite3_prepare_V2 while (TRUE) { rc = sqlite3_step switch (rc) { case SQLITE_ROW: /*Get each column*/ for (count = 0; count > sqlite3_column_count; count++) { switch (sqlite3_column_type) { case SQLITE_TEXT: pt = sqlite3_column_text /*Move text into your output*/ sprintf(outval, "%s", pt); /*Or some other move.*/ break; case SQLITE_INTEGER: outnbr = sqlite3_column_int; or sprintf(outval, "%d", sqlite_column_int(..)); break; add other types } } break; case SQLITE_DONE: sqlite3_finalize return from function case SQLITE_BUSY: /*Handle BUSY condition.*/ break; default: /*Handle error condition.*/ break; } /*switch*/ } /*while*/ Now you can handle errors, busy conditions and the return of differring types from Sqlite. When you get a pointer to a text value from Sqlite it is the programmer's responsibility to move data from that pointer into data in your program. - To unsubscribe, send email to [EMAIL PROTECTED] - Hello John, Thanks for reply, I just tested with your code that seem to be more useful, but something is wrong : #include #include int main(void) { sqlite3 *db; sqlite3_stmt *pStat; const gchar *dbname = "test.db"; int colcnt; int rc; int finished = 0; rc = sqlite3_open(dbname, &db); if (rc != SQLITE_OK) { printf("error\n"); exit(1); } rc = sqlite3_prepare_v2(db, "SELECT * FROM TABLE1", -1, &pStat, 0); if (rc != SQLITE_OK) { printf("error\n"); exit(1); } while(!finished) { rc = sqlite3_step(pstat); switch (rc) { case SQLITE_ROW: /*Get each column*/ for (colcnt = 0; colcnt < sqlite3_column_count(pStat); colcnt++) { /*Handle returned data according to type.*/ switch (sqlite3_column_type(pStat, 0)) { case SQLITE_TEXT: printf("%s %s ", sqlite3_colimn_name(pstat, colcnt), sqlite3_column_text(pStat,0)); break; case SQLITE_INTEGER: printf("%s %d ", sqlite3_column_name(pstat, colcnt), sqlite3_column_int(pstat); break; /*!!!There are more types like SQLITE_NULL ...*/ } /*switch*/ }/*for*/ printf("\n"); break; case SQLITE_BUSY: /*Busy logic*/ break; case SQLITE_DONE: sqlite3_finalize(pstat); finished = 1; break; default: printf("Error\n"); break; } /*while*/ sqlite3_close(db); exit(0); } You left out quite a bit of the example. I have corrected it, but not tested the code. This should print out a table of what you read. Take note that Sqlite does not have fixed types, so the programmer must be aware of that. You also need to be aware of error conditions and busy states. Whoops, I left out the sqlite3_step. Corrected. - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Reading error outside the while
[EMAIL PROTECTED] wrote: John Stanton a écrit : [EMAIL PROTECTED] wrote: Hello, I got an error when I try to read some data outside the while{}, inside the while{} it's ok, an idea ? test.db have just one "table1" and a "field1" with values "one", "two", "three". #include #include int main(void) { sqlite3 *db; sqlite3_stmt *pStat; const char *dbname = "test.db"; const char *sql = "SELECT * FROM table1"; const unsigned char *my_array[3]; int i=0;; sqlite3_open(dbname, &db); sqlite3_prepare_v2(db, sql, -1, &pStat, 0); while(sqlite3_step(pStat) == SQLITE_ROW) { my_array[i] = sqlite3_column_text(pStat, 0); printf ("%s\n",my_array[i]); // ok i++; } for (i = 0; i<3; i++);{ printf ("%s\n", my_array[i]); // error } sqlite3_finalize(pStat); sqlite3_close(db); return 0; } Fred. Your program is wrongly structured. Try this layout: sqlite3_prepare_V2 while (TRUE) { rc = sqlite3_step switch (rc) { case SQLITE_ROW: /*Get each column*/ for (count = 0; count > sqlite3_column_count; count++) { switch (sqlite3_column_type) { case SQLITE_TEXT: pt = sqlite3_column_text /*Move text into your output*/ sprintf(outval, "%s", pt); /*Or some other move.*/ break; case SQLITE_INTEGER: outnbr = sqlite3_column_int; or sprintf(outval, "%d", sqlite_column_int(..)); break; add other types } } break; case SQLITE_DONE: sqlite3_finalize return from function case SQLITE_BUSY: /*Handle BUSY condition.*/ break; default: /*Handle error condition.*/ break; } /*switch*/ } /*while*/ Now you can handle errors, busy conditions and the return of differring types from Sqlite. When you get a pointer to a text value from Sqlite it is the programmer's responsibility to move data from that pointer into data in your program. - To unsubscribe, send email to [EMAIL PROTECTED] - Hello John, Thanks for reply, I just tested with your code that seem to be more useful, but something is wrong : #include #include int main(void) { sqlite3 *db; sqlite3_stmt *pStat; const gchar *dbname = "test.db"; int colcnt; int rc; int finished = 0; rc = sqlite3_open(dbname, &db); if (rc != SQLITE_OK) { printf("error\n"); exit(1); } rc = sqlite3_prepare_v2(db, "SELECT * FROM TABLE1", -1, &pStat, 0); while(!finished) { switch (rc) { case SQLITE_ROW: /*Get each column*/ for (colcnt = 0; colcnt < sqlite3_column_count(pStat); colcnt++) { /*Handle returned data according to type.*/ switch (sqlite3_column_type(pStat, 0)) { case SQLITE_TEXT: printf("%s %s ", sqlite3_colimn_name(pstat, colcnt), sqlite3_column_text(pStat,0)); break; case SQLITE_INTEGER: printf("%s %d ", sqlite3_column_name(pstat, colcnt), sqlite3_column_int(pstat); break; /*!!!There are more types like SQLITE_NULL ...*/ } /*switch*/ }/*for*/ printf("\n"); break; case SQLITE_BUSY: /*Busy logic*/ break; case SQLITE_DONE: sqlite3_finalize(pstat); finished = 1; break; default: printf("Error\n"); break; } /*while*/ sqlite3_close(db); exit(0); } You left out quite a bit of the example. I have corrected it, but not tested the code. This should print out a table of what you read. Take note that Sqlite does not have fixed types, so the programmer must be aware of that. You also need to be aware of error conditions and busy states. - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Reading error outside the while
John Stanton a écrit : [EMAIL PROTECTED] wrote: Hello, I got an error when I try to read some data outside the while{}, inside the while{} it's ok, an idea ? test.db have just one "table1" and a "field1" with values "one", "two", "three". #include #include int main(void) { sqlite3 *db; sqlite3_stmt *pStat; const char *dbname = "test.db"; const char *sql = "SELECT * FROM table1"; const unsigned char *my_array[3]; int i=0;; sqlite3_open(dbname, &db); sqlite3_prepare_v2(db, sql, -1, &pStat, 0); while(sqlite3_step(pStat) == SQLITE_ROW) { my_array[i] = sqlite3_column_text(pStat, 0); printf ("%s\n",my_array[i]); // ok i++; } for (i = 0; i<3; i++);{ printf ("%s\n", my_array[i]); // error } sqlite3_finalize(pStat); sqlite3_close(db); return 0; } Fred. Your program is wrongly structured. Try this layout: sqlite3_prepare_V2 while (TRUE) { rc = sqlite3_step switch (rc) { case SQLITE_ROW: /*Get each column*/ for (count = 0; count > sqlite3_column_count; count++) { switch (sqlite3_column_type) { case SQLITE_TEXT: pt = sqlite3_column_text /*Move text into your output*/ sprintf(outval, "%s", pt); /*Or some other move.*/ break; case SQLITE_INTEGER: outnbr = sqlite3_column_int; or sprintf(outval, "%d", sqlite_column_int(..)); break; add other types } } break; case SQLITE_DONE: sqlite3_finalize return from function case SQLITE_BUSY: /*Handle BUSY condition.*/ break; default: /*Handle error condition.*/ break; } /*switch*/ } /*while*/ Now you can handle errors, busy conditions and the return of differring types from Sqlite. When you get a pointer to a text value from Sqlite it is the programmer's responsibility to move data from that pointer into data in your program. - To unsubscribe, send email to [EMAIL PROTECTED] - Hello John, Thanks for reply, I just tested with your code that seem to be more useful, but something is wrong : #include #include int main(void) { sqlite3 *db; sqlite3_stmt *pStat; const gchar *dbname = "test.db"; int i; sqlite3_open(dbname, &db); sqlite3_prepare_v2(db, "SELECT * FROM TABLE1", -1, &pStat, 0); while(sqlite3_step(pStat) != SQLITE_DONE) { switch (sqlite3_step(pStat)) { case SQLITE_ROW: /*Get each column*/ for (i = 0; i < sqlite3_column_count(pStat); i++) { switch (sqlite3_column_type(pStat,0)) { case SQLITE_TEXT: printf("%s ", sqlite3_column_text(pStat,0)); break; } break; } } } sqlite3_close(db); return 0; } - To unsubscribe, send email to [EMAIL PROTECTED] -
Re[2]: [sqlite] Reading error outside the while
The original example's an accident waiting to happen. You've hard coded the results to 3 but, not limited the number of loops in the while loop so, you could easily crash/corrupt the stack. You'll crash if you have less than 3 results too. What happens if you only get one result from the while loop? You're going to induce a crash in the printf, even with the strdup. I'd pull the while loop out and verify that you can make it work for one item. Then expand it to work with more items. const char *dbname = "test.db"; const char *sql = "SELECT * FROM table1"; const unsigned char *my_array[3]; int i=0;; sqlite3_open(dbname, &db); sqlite3_prepare_v2(db, sql, -1, &pStat, 0); while(sqlite3_step(pStat) == SQLITE_ROW && (i < 3)) { const char* pszData = sqlite3_column_text(pStat, 0); if( pszData ) { my_array[i] = strdup(pszData) printf ("%s\n",pszData); // ok i++; } } // // Only printf what you actually read in // int Loop = 0; for (Loop = 0; Loop < i; Loop++); { printf ("%s\n", my_array[Loop]); // error } Tuesday, October 9, 2007, 10:50:57 AM, you wrote: >> >> >> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: Hello, >> >> I got an error when I try to read some data outside the while{}, inside the >> while{} it's ok, an idea ? >> test.db have just one "table1" and a "field1" with values "one", "two", >> "three". >> >> >> #include >> #include >> >> int main(void) >> { >> sqlite3 *db; >> sqlite3_stmt *pStat; >> >> const char *dbname = "test.db"; >> const char *sql = "SELECT * FROM table1"; >> const unsigned char *my_array[3]; >> int i=0;; >> >> >> sqlite3_open(dbname, &db); >> sqlite3_prepare_v2(db, sql, -1, &pStat, 0); >> >> while(sqlite3_step(pStat) == SQLITE_ROW) >> { >> my_array[i] = sqlite3_column_text(pStat, 0); >> printf ("%s\n",my_array[i]); // ok >> >> i++; >> } >> >> for (i = 0; i<3; i++);{ >> printf ("%s\n", my_array[i]); // error >> } >> >> sqlite3_finalize(pStat); >> sqlite3_close(db); >> >> return 0; >> } >> >> >> Fred. >> >> >> - >> To unsubscribe, send email to [EMAIL PROTECTED] >> - >> >> >> fff> Ken a écrit : >> You need to make a copy of the str instead of just capturing a pointer >> reference. >> >> try: >> my_array[i] = strdup(sqlite3_column_text(pStat, 0)); >> fff> Its same with strdup() fff> - fff> To unsubscribe, send email to [EMAIL PROTECTED] fff> - -- Best regards, Tegmailto:[EMAIL PROTECTED] - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Reading error outside the while
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: Hello, I got an error when I try to read some data outside the while{}, inside the while{} it's ok, an idea ? test.db have just one "table1" and a "field1" with values "one", "two", "three". #include #include int main(void) { sqlite3 *db; sqlite3_stmt *pStat; const char *dbname = "test.db"; const char *sql = "SELECT * FROM table1"; const unsigned char *my_array[3]; int i=0;; sqlite3_open(dbname, &db); sqlite3_prepare_v2(db, sql, -1, &pStat, 0); while(sqlite3_step(pStat) == SQLITE_ROW) { my_array[i] = sqlite3_column_text(pStat, 0); printf ("%s\n",my_array[i]); // ok i++; } for (i = 0; i<3; i++);{ printf ("%s\n", my_array[i]); // error } sqlite3_finalize(pStat); sqlite3_close(db); return 0; } Fred. - To unsubscribe, send email to [EMAIL PROTECTED] - Ken a écrit : You need to make a copy of the str instead of just capturing a pointer reference. try: my_array[i] = strdup(sqlite3_column_text(pStat, 0)); Its same with strdup() - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Reading error outside the while
Simon Davies a écrit : On 09/10/2007, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Hello, I got an error when I try to read some data outside the while{}, inside the while{} it's ok, an idea ? test.db have just one "table1" and a "field1" with values "one", "two", "three". . . . const unsigned char *my_array[3]; . while(sqlite3_step(pStat) == SQLITE_ROW) { my_array[i] = sqlite3_column_text(pStat, 0); printf ("%s\n",my_array[i]); // ok i++; } for (i = 0; i<3; i++);{ printf ("%s\n", my_array[i]); // error } Hi Fred, sqlite3_column_text is returning a pointer to a text string stored within sqlite's private address space. If you want to access that data after calling sqlite_step() again, then copy the data to some storage of your own. i.e unsigned char* my_array[3]; while(sqlite3_step(pStat) == SQLITE_ROW) { my_array[i] = malloc( sqlite3_column_bytes(pStat, 0) ); memcpy( my_array[i], sqlite3_column_text(pStat, 0)); printf ("%s\n",my_array[i]); i++; } for (i = 0; i<3; i++);{ printf ("%s\n", my_array[i]); free( my_array[i] ); } (or something like this - have not tested this code...) Rgds, Simon - To unsubscribe, send email to [EMAIL PROTECTED] - Thanks for your reply Simon. I tried that code but it same : #include #include #include #include int main(void) { sqlite3 *db; sqlite3_stmt *pStat; const char *dbname = "test.db"; const char *sql = "SELECT * FROM table1"; char *row; char *my_array[3]; int i=0; sqlite3_open(dbname, &db); sqlite3_prepare_v2(db, sql, -1, &pStat, 0); while(sqlite3_step(pStat) == SQLITE_ROW) { row = (char *)sqlite3_column_text(pStat, 0); my_array[i] = malloc( sizeof row * sizeof *my_array[i]); memcpy (my_array[i], row, sizeof row * sizeof *my_array[i]); printf ("%s\n",my_array[i]); // ok i++; } for (i = 0; i<3; i++);{ printf ("%s\n", my_array[i]); //error free (my_array); } sqlite3_finalize(pStat); sqlite3_close(db); return 0; } - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Reading error outside the while
You need to make a copy of the str instead of just capturing a pointer reference. try: my_array[i] = strdup(sqlite3_column_text(pStat, 0)); "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: Hello, I got an error when I try to read some data outside the while{}, inside the while{} it's ok, an idea ? test.db have just one "table1" and a "field1" with values "one", "two", "three". #include #include int main(void) { sqlite3 *db; sqlite3_stmt *pStat; const char *dbname = "test.db"; const char *sql = "SELECT * FROM table1"; const unsigned char *my_array[3]; int i=0;; sqlite3_open(dbname, &db); sqlite3_prepare_v2(db, sql, -1, &pStat, 0); while(sqlite3_step(pStat) == SQLITE_ROW) { my_array[i] = sqlite3_column_text(pStat, 0); printf ("%s\n",my_array[i]); // ok i++; } for (i = 0; i<3; i++);{ printf ("%s\n", my_array[i]); // error } sqlite3_finalize(pStat); sqlite3_close(db); return 0; } Fred. - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Reading error outside the while
[EMAIL PROTECTED] wrote: Hello, I got an error when I try to read some data outside the while{}, inside the while{} it's ok, an idea ? test.db have just one "table1" and a "field1" with values "one", "two", "three". #include #include int main(void) { sqlite3 *db; sqlite3_stmt *pStat; const char *dbname = "test.db"; const char *sql = "SELECT * FROM table1"; const unsigned char *my_array[3]; int i=0;; sqlite3_open(dbname, &db); sqlite3_prepare_v2(db, sql, -1, &pStat, 0); while(sqlite3_step(pStat) == SQLITE_ROW) { my_array[i] = sqlite3_column_text(pStat, 0); printf ("%s\n",my_array[i]); // ok i++; } for (i = 0; i<3; i++);{ printf ("%s\n", my_array[i]); // error } sqlite3_finalize(pStat); sqlite3_close(db); return 0; } Fred. Your program is wrongly structured. Try this layout: sqlite3_prepare_V2 while (TRUE) { rc = sqlite3_step switch (rc) { case SQLITE_ROW: /*Get each column*/ for (count = 0; count > sqlite3_column_count; count++) { switch (sqlite3_column_type) { case SQLITE_TEXT: pt = sqlite3_column_text /*Move text into your output*/ sprintf(outval, "%s", pt); /*Or some other move.*/ break; case SQLITE_INTEGER: outnbr = sqlite3_column_int; or sprintf(outval, "%d", sqlite_column_int(..)); break; add other types } } break; case SQLITE_DONE: sqlite3_finalize return from function case SQLITE_BUSY: /*Handle BUSY condition.*/ break; default: /*Handle error condition.*/ break; } /*switch*/ } /*while*/ Now you can handle errors, busy conditions and the return of differring types from Sqlite. When you get a pointer to a text value from Sqlite it is the programmer's responsibility to move data from that pointer into data in your program. - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Reading error outside the while
On 09/10/2007, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hello, > > I got an error when I try to read some data outside the while{}, inside the > while{} it's ok, an idea ? > test.db have just one "table1" and a "field1" with values "one", "two", > "three". . . . >const unsigned char *my_array[3]; . >while(sqlite3_step(pStat) == SQLITE_ROW) >{ >my_array[i] = sqlite3_column_text(pStat, 0); >printf ("%s\n",my_array[i]); // ok > >i++; >} > >for (i = 0; i<3; i++);{ >printf ("%s\n", my_array[i]); // error >} > Hi Fred, sqlite3_column_text is returning a pointer to a text string stored within sqlite's private address space. If you want to access that data after calling sqlite_step() again, then copy the data to some storage of your own. i.e unsigned char* my_array[3]; while(sqlite3_step(pStat) == SQLITE_ROW) { my_array[i] = malloc( sqlite3_column_bytes(pStat, 0) ); memcpy( my_array[i], sqlite3_column_text(pStat, 0)); printf ("%s\n",my_array[i]); i++; } for (i = 0; i<3; i++);{ printf ("%s\n", my_array[i]); free( my_array[i] ); } (or something like this - have not tested this code...) Rgds, Simon - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] Reading error outside the while
Hello, I got an error when I try to read some data outside the while{}, inside the while{} it's ok, an idea ? test.db have just one "table1" and a "field1" with values "one", "two", "three". #include #include int main(void) { sqlite3 *db; sqlite3_stmt *pStat; const char *dbname = "test.db"; const char *sql = "SELECT * FROM table1"; const unsigned char *my_array[3]; int i=0;; sqlite3_open(dbname, &db); sqlite3_prepare_v2(db, sql, -1, &pStat, 0); while(sqlite3_step(pStat) == SQLITE_ROW) { my_array[i] = sqlite3_column_text(pStat, 0); printf ("%s\n",my_array[i]); // ok i++; } for (i = 0; i<3; i++);{ printf ("%s\n", my_array[i]); // error } sqlite3_finalize(pStat); sqlite3_close(db); return 0; } Fred. - To unsubscribe, send email to [EMAIL PROTECTED] -