ฉันจะแทรกข้อมูลบางอย่างลงในฐานข้อมูล Sqlite 3 ได้อย่างไร

ด้วยโค้ดต่อไปนี้ ฉันกำลังดึงข้อมูลจาก Db แต่ฉันต้องแทรกข้อมูลบางส่วนลงในฐานข้อมูล Sqlite3 ด้วยโค้ดนี้ก่อนเลือกคำสั่ง ใครสามารถบอกฉันได้ว่าฉันต้องวางแบบสอบถามแบบแทรกไว้ที่ไหนและฉันจะดำเนินการได้อย่างไร

ฉันกำลังเลือกข้อมูลผ่านรหัสต่อไปนี้:

sqlite3* database;

- (void)initializeDatabase 
{   
    list=[[NSMutableArray alloc] init];
    BOOL success;
    NSFileManager *filemanager=[NSFileManager defaultManager];
    NSError *error;
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory= [paths objectAtIndex:0];
    NSString *writablePath=[documentsDirectory stringByAppendingPathComponent:@"SymbolTalk.sqlite"];
    success=[filemanager fileExistsAtPath:writablePath];
    if(!success)
    {
        NSString *defaultDBPath=[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"SymbolTalk.sqlite"];
        success=[filemanager copyItemAtPath:defaultDBPath toPath:writablePath error:&error];
        if(!success)
        {
            NSAssert1(0,@"Failed to create writable databasefile withw message %@.",[error localizedDescription]);
        }
    }

    //Specify where to get the database from
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory= [paths objectAtIndex:0];
    NSString *path=[documentsDirectory stringByAppendingPathComponent:@"SymbolTalk.sqlite"];

    //Open the database
    //might have to make database as property
    if(sqlite3_open([path UTF8String], &dataBase) ==SQLITE_OK)
    {
        const char *sql="select filename from scenes";
        sqlite3_stmt *statement;

        if(sqlite3_prepare(dataBase, sql, -1, &statement, NULL) == SQLITE_OK)
        {
            while (sqlite3_step(statement) == SQLITE_ROW) 
            {
                //NSLog(@"%@",[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 0)]);
                [list addObject:[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 0)]];
            }
        }
    }
}

person Vipin    schedule 22.06.2011    source แหล่งที่มา
comment
คุณได้รับข้อผิดพลาดอะไร?   -  person Deepak Danduprolu    schedule 22.06.2011
comment
รหัสนี้ใช้สำหรับการดึงข้อมูล ฉันต้องใส่รหัสเพื่อแทรก   -  person Vipin    schedule 22.06.2011