Wondering if anyone has used SQLite. I'm having trouble with the basics.
sqlite3_get_table function.

The Apress book 'The Definitive Guide to SQLite' provides the following example. The first problem is that when declaring char *result[]; Things start to go wrong.

I get an error message saying that 'the size of result can't be determined'.
On top of this, I can't seem to get the &nrows and &ncols arguments right. The compiler keeps telling me that I can't compare an int to a char. I'm just not sure how to interpret the arguments for this. Specifically in the Sqlite3_get_table function. The book by Apress, 'The Definitive Guide to Sqlite' I'm finding very difficult to follow.. Would anyone be able to provides some tips on how to get the below working. I'll put my table below the code.

int main(int argc, char **argv)
{
    /* Connect to database, etc. */

    char *result[];
    sql = "select * from episodes;";
    rc = sqlite3_get_table(db, sql, &result, &nrows, &ncols, &zErr);

    /* Do something with data */

    /* Free memory */
    sqlite3_free_table(result)



id|value
1|eenie
2|meenie
3|miny
4|mo
5|moo

Thanks to anyone who can help me..

Recommended Answers

All 3 Replies

You are using a function that has been depreciated, not intended to be used in new programs. http://www.sqlite.org/c3ref/free_table.html

This is a legacy interface that is preserved for backwards compatibility. Use of this interface is not recommended.

Agreed, but it has still been maintained, so it still should work.

I get an error message saying that 'the size of result can't be determined'.

That's because you declared it with unspecified array size on line 5 and that's illegal in c++. Change it to this: char **result = NULL;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.