【发布时间】:2014-12-17 04:43:37
【问题描述】:
已编辑,试图更好地解释上下文。
我想在 Xcode 中删除 SQLite DB 上的记录。
记录的值添加如下:
sql = [NSString stringWithFormat:@"INSERT INTO tblTextos (\"txtMostrado\", \"txtCopiado\") VALUES(\"%@\", \"%@\")", [txt2BS stringValue], [txt2BC stringValue]];// Where txt2BS and txt2BC are NSTextField
要删除记录,我使用下一句:
sentenciaSQL = [NSString stringWithFormat:@"DELETE FROM tblTextos WHERE txtMostrado = '%@'", txtaborrar]; //where tblTextos is a table, txtMostrado a field (text field) and txtaborrar a String variable (NSString).
问题是当txtaborrar 变量里面只有一个数字时,例如22。然后句子不起作用并且记录没有被删除。
我尝试使用以下内容将变量值强制为字符串:
txtaborrar = [NSString stringWithFormat: @"%@",[comboTodos stringValue]];//where Combotodos is a combo
但它不起作用。如果 txtaborrar 值只是一个数字,记录不会被删除。
很遗憾,该字段的值可以是数值或文本值。
非常欢迎任何帮助!
【问题讨论】:
-
感谢您编辑帖子。下次我会注意你的更正
标签: objective-c sqlite nsstring