2010-12-08 2 views
-3

Я пытаюсь сохранить значения в базе данных SQLite в iPhone sdk. Когда я исполняю эту линиюSQlite - iPhone sdk - Assertion Failed

 
[database executeNonQuery:strQuery1]; 

Это сообщение выводится на консоль.

SQLite Шаг Ошибка: ограничение не удалось

мне нужна помощь на срочной основе, как я должен представить проект сегодня. Я пробовал с 2 дней, и это сводит меня с ума.

Heres brief Информация о файле заголовка Я объявила его в заголовке контроллера View, используя эту строку.

 
Sqlite *database; 

And heres the header of SQlite

 
@interface Sqlite : NSObject 
{ 
    NSInteger busyRetryTimeout; 
    NSString *filePath; 
    sqlite3 *_db; 
} 

@property (readwrite) NSInteger busyRetryTimeout; 
@property (readonly) NSString *filePath; 
+ (NSString *)createUuid; 
+ (NSString *)version; 
- (id)initWithFile:(NSString *)filePath; 
- (BOOL)open:(NSString *)filePath; 
- (void)close; 
- (NSInteger)errorCode; 
- (NSString *)errorMessage; 
- (NSArray *)executeQuery:(NSString *)sql, ...; 
- (NSArray *)executeQuery:(NSString *)sql arguments:(NSArray *)args; 
- (BOOL)executeNonQuery:(NSString *)sql, ...; 
- (BOOL)executeNonQuery:(NSString *)sql arguments:(NSArray *)args; 
- (BOOL)commit; 
- (BOOL)rollback; 
- (BOOL)beginTransaction; 
- (BOOL)beginDeferredTransaction; 

+0

Каков запрос, который вы выполняете? Пожалуйста, `NSLog (@" Query:% @ ", strQuery1);` прямо до или после этой первой строки и поделитесь выходом здесь. – mvds 2010-12-08 11:19:42

+0

@mvds Я проверил его в SQLite Manager и отлично работает. – 2010-12-08 11:48:10

+0

A. Вам нужна помощь? Если нет: уходи. Иначе: поделитесь полной проблемой здесь. Тот факт, что вы используете заголовок sqlite, в то время как вы получаете сообщение об ошибке из sqlite, по крайней мере свидетельствует о том, что вы не тот, кто может определить, какая информация полезна для диагностики проблемы. – mvds 2010-12-09 23:59:43

ответ

1

If only there was some sort of on line resource where you could go and enter "constraint failed" in a search box to get the answer.

Since that is sadly not the case, I'll tell you. The problem is most likely that you are violating a key constraint with your query. It's hard to say without seeing the query and the database schema, but you might be, for instance, trying to insert a row with a duplicate primary key or insert a row with a foreign key that does not exist in the referenced table.

0

Executing it in the SQLliteManager won't help you, it's a bit different on the iPhone. You should be able to get an error from the Database using the errorMessage property. And yes, also give us the query itself.

0

First of all, just share the query. You're starting to piss people off.

Second of all, are you sure the mystery query isn't an INSERT запрос, и вы уверены, что он не выполнен дважды вашим секретным кодом?

Это объясняет, что вы не видите ошибку при выполнении запроса (один раз) вручную.

Смежные вопросы