开发者

sqlite query problem in iphone sdk?

开发者 https://www.devze.com 2023-01-27 06:27 出处:网络
hi how can i include NSString in the following query.House is as NSString.If i give like following directly, it works fine.but i want to execute through NSString.

hi how can i include NSString in the following query.House is as NSString.If i give like following directly, it works fine.but i want to execute through NSString.

 NSString* str = @"House";

 const char *sqlStatement = "select rowid from 开发者_高级运维PlaceTable where name = 'MyUncleHouse'";


You can use NSString's method called UTF8String as follows:

NSString *str = ["SELECT rowid from PlaceTable where name = '" stringByAppendingFormat:@"%@'",my_uncle_house_str];

const char *sql_statement = [str UTF8String];


You can write like this

NSString* str = @"MyUncleHouse";

NSString* string = [NSString stringWithFormat:@"select rowid from PlaceTable where name = '%@',str];

const char *sql_statement = [str UTF8String];

0

精彩评论

暂无评论...
验证码 换一张
取 消