大家好
我需要在现有的表中添加一列,那么如何通过obj c更改sqlite数据库中的表结构呢?我正在使用以下代码向表中插入数据,同样地,我该如何编写更新表的方法?
- (void) InsertRecord {
if(addStmt == nil) {
const char *sql = "insert into tbl_Users(FirstName,MiddleName) 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, [strFirstName UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(addStmt, 2, [strMiddleName UTF8String], -1, SQLITE_TRANSIENT);
//sqlite3_bind_text(addStmt, 3, [strLogin UTF8String], -3, SQLITE_TRANSIENT);
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
//productID = sqlite3_last_insert_rowid(database);
//Reset the add statement.
sqlite3_reset(addStmt);
能有人帮助我吗?提前谢谢。