0
我我將使用下面的代碼,但數據的數據到數據庫在數據庫中沒有插入數據插入數據的基礎上 我用下面的代碼如何在iphone
我將數據插入到iPhone應用,但它確實不要將
我有表survey_question_master(question_id,QUESTION_TEXT,question_type)
- (void) addCoffee {
if(addStmt == nil) {
const char *sql = "insert into survey_question_master(question_text,question_type) Values(? ,?)";
if(sqlite3_prepare_v2(database, sql, -1, &addStmt, NULL) != SQLITE_OK)
NSAssert1(0, @"Error while creating add statement. '%s'", sqlite3_errmsg(database));
}
sqlite3_bind_text(addStmt, 1, [question_text UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(addStmt, 2, [question_type UTF8String], -1, SQLITE_TRANSIENT);
if(SQLITE_DONE != sqlite3_step(addStmt))
NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database));
else
question_ID = sqlite3_last_insert_rowid(database);
//Reset the add statement.
sqlite3_reset(addStmt);
}
- (void) addCoffee:(DataController *)coffeeObj {
//Add it to the database.
[coffeeObj addCoffee];
//Add it to the coffee array.
[coffeeArray addObject:coffeeObj];
NSLog(@"Succeessfully Added");
}
如何ü讀取數據庫是否插入數據或不? – 2012-07-30 07:54:57
我打開從sqlite管理器的數據庫來查看插入的數據 – user1553768 2012-07-30 07:55:46
然後你是否收到錯誤消息?或者它執行但數據庫中沒有任何內容? – 2012-07-30 08:02:02