An autoincrement field is already included with SQLite. Select ROWID from a table to get the unique row identification. Here is some REALBasic code that selects the ROWID along with the other columns in the table and displays it in a ListBox:
UtilSet.LBAP.DeleteAllRows db= New REALSQLdatabase dbFile = GetFolderItem("mcj.rsd") db.DatabaseFile=dbFile If db.Connect() then rs = db.SQLSelect("select *,ROWID from people") While Not rs.eof UtilSet.LBAP.AddRow rs.IdxField(3).StringValue UtilSet.LBAP.Cell(UtilSet.LBAP.LastIndex, 1)=rs.IdxField(2).StringValue UtilSet.LBAP.Cell(UtilSet.LBAP.LastIndex, 2)=rs.IdxField(1).StringValue UtilSet.LBAP.Cell(UtilSet.LBAP.LastIndex, 3)=rs.IdxField(4).StringValue rs.MoveNext Wend else Beep MsgBox "The database couldn't be opened." end if db.Close |
Here is what the output looks like:
For more information, see this SQLite Autoincrement reference page.