일부 데이터를 mydatabase.sqlite에 삽입하고 싶지만 문제가 있습니다. 데이터를 삽입 할 때 오류 메시지가 나타나지 않지만 데이터베이스를 열면 데이터가 표시되지 않습니다. 어떤 데이터도 없습니다. SQLite 객관적인 C 데이터를 삽입하십시오
이
은 MyClass의에서 addCoffee 방법입니다 :if(addStmt == nil) {
const char *sql = "insert into records(Date, Latitude, Longitude) 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, [Date UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_double(addStmt, 2, [Latitude doubleValue]);
sqlite3_bind_double(addStmt, 3, [Longitude doubleValue]);
if(SQLITE_DONE != sqlite3_step(addStmt))
NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database));
else
//SQLite provides a method to get the last primary key inserted by using sqlite3_last_insert_rowid
recordID = sqlite3_last_insert_rowid(database);
//Reset the add statement.
sqlite3_reset(addStmt);
전송 데이터 :
iDailyAppDelegate *appDelegate = (iDailyAppDelegate *)[[UIApplication sharedApplication] delegate];
//Create a MyClass Object.
MyClass *coffeeObj = [[MyClass alloc] initWithPrimaryKey:0];
coffeeObj.Date = dateInString;
NSDecimalNumber *temp = [[NSDecimalNumber alloc] initWithString:first];
coffeeObj.Latitude = temp;
NSDecimalNumber *temp2 = [[NSDecimalNumber alloc] initWithString:second];
coffeeObj.Longitude = temp2;
[temp release];
coffeeObj.isDirty = NO;
coffeeObj.isDetailViewHydrated = YES;
//Add the object
[appDelegate addCoffee:coffeeObj];
'BEGIN TRANSACTION'을 (를) 실행했을 가능성이 있습니다. 해당 'COMMIT'을 실행하지 않았습니까? –
미안 내가 뭘 할 수있어, 내가 너를 이해하지 못 했니 ??? –
제발 helppp mee !! –