Hi,
you have to add "sqlite3.dylib " and import the "sqlite3.h" file.
#import "sqlite3.h"
+(BOOL)deleteAllColors
{
BOOL retVal = FALSE;
sqlite3 *database = nil;
sqlite3_stmt *stmt = nil;
NSString *sql = nil;
NSInteger op_status = sqlite3_open([[ApplicationData returnDatabasePath] UTF8String], &database);
@try
{
if (op_status==SQLITE_OK)
{
sql = [NSString stringWithFormat:@"delete from Color"];
op_status = sqlite3_prepare(database, [sql UTF8String], -1, &stmt, nil);
if (op_status!=SQLITE_OK)
{
goto end_of_transaction;
}
op_status = sqlite3_step(stmt);
if (op_status != SQLITE_DONE)
{
goto end_of_transaction;
}
retVal = TRUE;
}
end_of_transaction:
if (stmt!=nil) {
sqlite3_finalize(stmt);
stmt=nil;
}
if (database!=nil) {
sqlite3_close(database);
database=nil;
}
sql = nil;
}
@catch (NSException * e)
{
// thhrow exception
if (stmt!=nil) {
sqlite3_finalize(stmt);
stmt=nil;
}
if (database!=nil) {
sqlite3_close(database);
database=nil;
}
sql = nil;
}
return retVal;
}
No comments:
Post a Comment