当我尝试获取具有多个表的数据库时,我根本没有数据。在正常情况下,当我尝试使用一个表获取数据库时,我可以获得所有数据,并且每件事都可以正常工作!
此函数应返回数据库中的表数:
-(NSInteger)GetTablesCount
{
[self openconnection];
const char * sql="select count(*) from sqlite_master where type='table'";
sqlite3_stmt *selectstatment;
if(sqlite3_prepare_v2(database,sql,-1,&selectstatment,Nil)==SQLITE_OK)
{
while(sqlite3_step(selectstatment)==SQLITE_ROW){
return sqlite3_column_int(selectstatment, 0);// return the number of tables
// int the case of multiple tables it returns 0...
}
}
return 0;
}
[self open connection]
打开与数据库的连接。