這裏是我的表,SQLite爲什麼不增加我的主鍵?
sqlStmt = [ [ NSString stringWithFormat:@"Create Table %@ (recordNo INTEGER PRIMARY KEY AUTOINCREMENT, noOfPlayer INTEGER, smallBlindAmt INTEGER, bigBlindAmt INTEGER , startingChips INTEGER, roundTimer INTEGER) " , SETTINGS_TABLE ] StringUsingEncoding:NSUTF8StringEncoding ] ;
插入查詢,
sqlStmt = [ [ NSString stringWithFormat: @"insert into %@ values (NULL,%d, %d ,%d ,%d ,%d)" , strTableName ,noOfPlayers, SmallAmt, BigAmt, StartingChips, RoundTime ] UTF8String ] ;
獲得最後一個記錄的記錄ID,
lastRecordNo = sqlite3_last_insert_rowid(dbObj);
的lastRecordNo始終爲0,而我無法插入另一個值因爲它給出的錯誤主鍵必須是唯一的。
我無法得到與之相關的問題?
如何獲取主鍵和自動增量的最後一個記錄ID。
我的插入查詢有什麼問題嗎?
任何人都可以用示例創建,插入和選擇查詢,其中主要是一個自動增量嗎?
奇怪...我也想知道... – Fortega 2009-05-29 11:47:21