Im new to using Xojo databases and I have built a SQLite Db for books. The routine I use for adding a single book works fine the first time but adding a 2nd book yields the error, The current row in the RecordSet is not editable (out of range).
The curious thing is that the routine I used to initially populate the Db from a listbox is essentially the same as this one below that fails.
[code]// Add a new row to the DB
// Reload the list
[quote=141712:@Brent Malcolm]Im new to using Xojo databases and I have built a SQLite Db for books. The routine I use for adding a single book works fine the first time but adding a 2nd book yields the error, The current row in the RecordSet is not editable (out of range).
[/quote]
This error usually relates to EDIT being called on a row in a reforest but that doesn’t seem to be related to the code you posted
Ok, I see three things that I find questionable but without seeing the whole method I can’t quite say if any are the cause.
[quote=141712:@Brent Malcolm]
newBook.Column("AuthorFirst") = AuthorFirst
newBook.Column("AuthorLast") = AuthorLast
newBook.Column("Title") = Title
newBook.Column("Notes") = Notes + " " + s
newBook.Column("Subject") = Subject
newBook.Column("PickupDate") = PickupDate[/quote]
First, are the values actual strings or fields holding the strings? E.g., should ‘AuthorFirst’ be ‘AuthorFirst.Text’ and so on?
Second, what is the value of ‘s’? You’re assigning ‘Notes + " " + s’ but ‘s’ has no value. If can’t be from a passed parameter since you Dim the variable at the top of the method.
[quote=141712:@Brent Malcolm]
[code] If app.DBError Then
MsgBox "DB Error: " + app.db.ErrorMessage
Return
End If
BooksRead.refreshListbox
[/code][/quote]
Third, what is DBError? Did you mean 'app.db.Error?
And as a final thought, are any of the fields, other than the primary key, set to UNIQUE to prevent duplicates? If so, are you possible trying to add a value that already exists in that row?
I would set a breakpoint at the start of the method and step through it to see exactly where the problem crops up. As Norman pointed out earlier, the error message you are getting is typically from an Edit not an Insert.