I want to take the record I receive back from the Database and programmatically make it a JSONItem with the column names as the JSON value labels. However, Xojo gives me a NilObjectException when I attempt the following. Why is this?
Dim rs As RecordSet = ExecuteSQLRS(SQL)
if rs <> nil then
While not rs.EOF
jItem = new JSONItem
for i As Integer = 0 to rs.FieldCount -1
jItem.Value(rs.IdxField(i).Name) = rs.idxField(i).NativeValue <<<<<<<<<
IdxField is one-based.
for i = 1 to rs.FieldCount
Thanx Tim. Don’t know how I missed that in the docs.
You should look into the new framework json handling over JSONItem. It resolves some issues and is much faster, even if you have to massage the data a bit more.
If you were coming from Microsoft’ s Jet DB the indexes are all zero based.
Yeh… and why is that ? .
Took me at least 15 min today to figure out what went wrong while getting data out of SQL Server database.
This is one of the improvements of the new framework, consistency. Everything is zero-based.
Does it mean, once Xojo switches completely to the new Framework, i have to refactor all code which relies on 1-based IdxField’s?
I think you mean, once you switch over completely to the new framework. The classic framework will be around for a long, long time, if not forever. But yes, that’s what it means.