void getTableData()
{
sqlite3_stmt *statement;
char *query = "select * from student";
if ( sqlite3_prepare(dbfile, query, -1, &statement, 0 ) == SQLITE_OK )
{
int ctotal = sqlite3_column_count(statement);
int res = 0;
while ( 1 )
{
res = sqlite3_step(statement);
if ( res == SQLITE_ROW )
{
for ( int i = 0; i < ctotal; i++ )
{
string s = (char*)sqlite3_column_text(statement, i);
cout << s << " " ;
}
cout << endl;
}
if ( res == SQLITE_DONE )
{
cout << "done " << endl;
break;
}
}
}
}
沒有留言:
張貼留言