插入数据库失败的SQLITE错误代码21

时间:2013-01-18 10:34:52

标签: iphone objective-c sqlite

代码是:

- (IBAction)AddExpenseButtonPressed:(id)sender {
    sqlite3 *database;

    NSString *sqlStatement = @"";

    if(sqlite3_open([dataBasePath UTF8String], &database) == SQLITE_OK)
    {
        sqlStatement = [NSString stringWithFormat:@"insert into Expenses (Vendor) values ('%@');",VendorName.text];

//        sqlStatement = [NSString stringWithFormat:@"insert into Expenses ( Date,Vendor,Comment,Rate) values ('%@','%@','%@');",DateText.text,VendorName.text,CommentText.text,RateText.text];

        NSLog(@"%@",sqlStatement);
        if (sqlite3_exec(database, [sqlStatement cStringUsingEncoding:NSUTF8StringEncoding], NULL, NULL, NULL) == SQLITE_OK)
        {
            NSLog(@"record inserted successfully!!");
        }

        sqlite3_close(database);
    }
     NSLog(@"Error is--------%d",sqlite3_errcode(database));

    [self.navigationController popViewControllerAnimated:YES];

}

0 个答案:

没有答案