I am populating a B4XTable with data from SQL server. I have found - at least with text data columns, if a value of null is returned from SQL then that column in the B4XTable is not cleared when you page through the data, it retains whatever value was on the previous page. It should be blank, or at the very least contain 'null'. This is a subtle bug that can lead to some very misleading results.
I have solved the problem by testing for null and replacing it with a zero length string before populating the B4XTable.
My code looks like this, except I have NZ'd the nullable columns to solve the problem for now.
I have solved the problem by testing for null and replacing it with a zero length string before populating the B4XTable.
My code looks like this, except I have NZ'd the nullable columns to solve the problem for now.
B4X:
Do While Crsr.NextRow = True
Dim M As Map
M.Initialize
M.Put("Os_JobNum", Crsr.GetString("Os_JobNum"))
M.Put("Os_ReleaseNum", Crsr.GetString("Os_ReleaseNum"))
M.Put("Os_SeqNum", Crsr.GetInt("Os_SeqNum"))
M.Put("Os_WCCode", Crsr.GetString("Os_WCCode"))
M.Put("Os_ID", Crsr.GetInt("Os_ID"))
M.Put("Os_StartbyDate", Crsr.GetString("Os_StartbyDate"))
M.Put("Scheduled", False)
'need an extra item in the array for the picture column that is the ""
data.Add(Array(Crsr.GetString("Pmp_PictureName"), "", Crsr.GetInt("Os_ID"), DateTime.DateParse(Crsr.GetString("Os_StartbyDate")), Crsr.GetString("Os_JobNum"), _
Crsr.GetInt("Os_ReleaseNum"), DADMod.NZ(Crsr.GetString("Jb_Status"), ""), DADMod.NZ(Crsr.GetString("Jb_Status2"), ""), DADMod.NZ(Crsr.GetString("Jb_Status3"), ""), DADMod.NZ(Crsr.GetString("Jb_Planner"), "") _
, Crsr.GetInt("Os_SeqNum"), Crsr.GetString("Jb_Part_Num"), Crsr.GetString("Jb_ItemNum"), DADMod.NZ(Crsr.GetString("Os_ProcessCode"), "") _
, Crsr.GetDouble("Hours"), Crsr.GetString("Os_FinishbyDate"), Crsr.GetString("Jr_FirstDueDate"), Crsr.GetString("Customer") _
, Crsr.GetInt("Jr_SchedulePriority"), DADMod.NZ(Crsr.GetString("Os_Note"), ""), Crsr.GetString("Jr_Released") _
))
Log(Crsr.GetString("Os_JobNum") & " " & Crsr.GetString("Jb_Status2"))
zx=zx+1
If zx = 12 Then
Sleep(0) 'forces view of what is loaded so far
End If
'Sleep(1)
Loop
' Log("Data: " & data)
Log("UnschOps: " & ((DateTime.Now - TTTTT) / 1000) & " Seconds " & zx & " Records")
Crsr.Close
UnSchedOpsList.SetData(data)
UnSchedOpsList.RefreshNow