我需要更新我的sqlite
表。所以我写了一个这样的查询
NSString *updateSQL = [NSString stringWithFormat: @"UPDATE LOCALPLAYLISTSONGS SET SONGNAME=\"%@\",SONGPATH=\"%@\" WHERE PLAYLISTNAME=\"%@\"",SongTitle,songPath,playlistName];
const char *update_stmt = [updateSQL UTF8String];
sqlite3_prepare_v2(database, update_stmt, -1, &statement, NULL);
if (sqlite3_step(statement) == SQLITE_DONE)
{
status=@"song Added";
}
else
{
status=@"Error occured";
}
问题是这总是显示状态为发生错误。我的查询有什么问题。请让我看看
谢谢
更新
-(NSString *)UpdateLocalPlaylist :(NSString *)playlistName :(NSString *)SongTitle :
(NSString *)songPath
{
NSLog(@"passed");
NSString *status;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
NSString *dbPath=[[NSString alloc]initWithString:[documentsDir stringByAppendingPathComponent:@"LocalSongs.sqlite"]];
NSLog(@"Database Path %@",dbPath);
sqlite3_stmt *statement;
if (sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK) {
NSLog(@"open");
NSString *updateSQL = [NSString stringWithFormat: @"UPDATE LOCALPLAYLISTSONGS SET SONGNAME=%@,SONGPATH=%@ WHERE PLAYLISTNAME=%@",SongTitle,songPath,playlistName];
const char *update_stmt = [updateSQL UTF8String];
sqlite3_prepare_v2(database, update_stmt, -1, &statement, NULL);
if (sqlite3_step(statement) == SQLITE_DONE)
{
status=@"song Added";
}
else
{
status=@"Error occured";
}
return status;
}
else
return @"Error Occured";
}