为什么查询无法插入数据

时间:2014-09-20 14:51:03

标签: ios sqlite

我在数据库中插入数据,我的查询对前四个元素工作正常但在此之后它给了我这个问题 我的代码是

//Specialdeals
-(void) insertDealsTipIntoSqlite:(NSString *)title andDetail:(NSString *)detail andStartdate:(NSString*)startDate andEnddate:(NSString*)endDate andImage:(NSString *)image andThumb:(NSString*)thumb andBranch:(NSString *)branch
{
    NSString *query = [NSString stringWithFormat:@"insert into SpecialDeals(title,detail,startDate,endDate,branch,pic,thumb) values('%@','%@','%@','%@','%@','%@','%@')", title,detail,startDate,endDate, branch ,image,thumb];
    [self InsUpdateDelData:query];

}

和我的失败日志

 Success Query: insert into SpecialDeals(title,detail,startDate,endDate,branch,pic,thumb) values('The Lounge Manic Mondays','Mighty Mondays Offer: Get 50% discount on foot massage on 29th Sept, 2014. Start booking your appointments from Thursday 25th Sept, 2014.','2014-09-29','2014-09-29','DHA & Gulberg lahore, Islamabad and Peshawar','20442014074407.jpg','20442014074407.jpg')

2014-09-20 19:44:13.432 Depilex[3761:60b] path is... /var/mobile/Applications/7090E701-CC89-40E7-B791-BBF89ACEA0F6/Documents/20442014074413.jpg
2014-09-20 19:44:13.453 Depilex[3761:60b] path is... /var/mobile/Applications/7090E701-CC89-40E7-B791-BBF89ACEA0F6/Documents/20442014074413.jpg


Success Query: insert into SpecialDeals(title,detail,startDate,endDate,branch,pic,thumb) values('The Lounge Manic Mondays','Mighty Mondays Offer: Get 50% off on shave on 22nd Sept, 2014. Start booking your appointments from Thursday 18th Sept, 2014.','2014-09-22','2014-09-22','DHA & Gulberg lahore , Islamabad & Peshawar','20442014074413.jpg','20442014074413.jpg')

2014-09-20 19:44:25.107 Depilex[3761:60b] path is... /var/mobile/Applications/7090E701-CC89-40E7-B791-BBF89ACEA0F6/Documents/20442014074424.jpg
2014-09-20 19:44:25.129 Depilex[3761:60b] path is... /var/mobile/Applications/7090E701-CC89-40E7-B791-BBF89ACEA0F6/Documents/20442014074425.jpg


Failure Query: insert into SpecialDeals(title,detail,startDate,endDate,branch,pic,thumb) values('The Lounge Student Ambassador Deal','The Lounge is looking for Student Ambassador in today's fast paced , modern, fashionable and trendy world !','2014-08-24','2014-09-29','DHA & Gulberg','20442014074424.jpg','20442014074425.jpg')

2014-09-20 19:44:25.131 Depilex[3761:60b] SQL ERROR: near "s": syntax error. In Statement: insert into SpecialDeals(title,detail,startDate,endDate,branch,pic,thumb) values('The Lounge Student Ambassador Deal','The Lounge is looking for Student Ambassador in today's fast paced , modern, fashionable and trendy world !','2014-08-24','2014-09-29','DHA & Gulberg','20442014074424.jpg','20442014074425.jpg')
2014-09-20 19:44:56.123 Depilex[3761:60b] path is... /var/mobile/Applications/7090E701-CC89-40E7-B791-BBF89ACEA0F6/Documents/20442014074451.jpg


   2014-09-20 19:44:56.146 Depilex[3761:60b] path is... /var/mobile/Applications/7090E701-CC89-40E7-B791-BBF89ACEA0F6/Documents/20442014074456.jpg
Failure Query: insert into SpecialDeals(title,detail,startDate,endDate,branch,pic,thumb) values('Sante Student Brand Ambassodor','Sante The Salon is looking for a smart motivated, Fabulous ,social butterfly to represent us in today's modern & fashionable world.','2014-09-15','2014-10-31','Gulberg lahore','20452014074527.jpg','20452014074528.jpg')
2014-09-20 19:45:28.198 Depilex[3761:60b] SQL ERROR: near "s": syntax error. In Statement: insert into SpecialDeals(title,detail,startDate,endDate,branch,pic,thumb) values('Sante Student Brand Ambassodor','Sante The Salon is looking for a smart motivated, Fabulous ,social butterfly to represent us in today's modern & fashionable world.','2014-09-15','2014-10-31','Gulberg lahore','20452014074527.jpg','20452014074528.jpg')

1 个答案:

答案 0 :(得分:0)

你的字符串有撇号...

Failure Query: insert into SpecialDeals(title,detail,startDate,endDate,branch,pic,thumb) values('The Lounge Student Ambassador Deal','The Lounge is looking for Student Ambassador in today's fast paced , modern, fashionable and trendy world !','2014-08-24','2014-09-29','DHA & Gulberg','20442014074424.jpg','20442014074425.jpg')

查看您说的详细信息字段

  

今天的

...

为了解决这个问题,只需加倍撇号就可以避开它。 EG。

  

当今的