Wish B4XTable

coldtech

Member
Licensed User
I spent quite awhile yesterday trying to determine why my code kept exploding calling SetData.

I did not properly create the columns and it was totally my overlooking it.

However, would it be possible to check the Columns list in the CreateTable procedure to just return if the count is 0 or throw an exception in future versions?

I found the 'CREATE TABLE" error thrown by the sql call to be very ambiguous.
 

Mahares

Expert
Licensed User
would it be possible to check the Columns list in the CreateTable procedure to just return if the count is 0 or throw an exception
Until Erel gets back to you with a more plausible answer, you can always check the number of B4XTable columns before applying the data list to it:
B4X:
If B4XTable1.Columns.Size =0 Then
        MsgboxAsync("Did you forget to create the B4XTable Columns", "B4XTable columns may be missing")
        Return
 End If
B4XTable1.SetData(Data)
Or trap the error:
B4X:
Try
    B4XTable1.SetData(Data)
Catch
     Log(LastException.Message)
     MsgboxAsync("Did you forget to create the B4XTable Columns", "B4XTable columns may be missing")
End Try
 

coldtech

Member
Licensed User
Until Erel gets back to you with a more plausible answer, you can always check the number of B4XTable columns before applying the data list to it:
B4X:
If B4XTable1.Columns.Size =0 Then
        MsgboxAsync("Did you forget to create the B4XTable Columns", "B4XTable columns may be missing")
        Return
 End If
B4XTable1.SetData(Data)
Or trap the error:
B4X:
Try
    B4XTable1.SetData(Data)
Catch
     Log(LastException.Message)
     MsgboxAsync("Did you forget to create the B4XTable Columns", "B4XTable columns may be missing")
End Try
I know, but when a new version of the lib ships it would be nice to not have to remember to reimplement.

Another option would be to show the grid with a single row/column "NO DATA DEFINED", which is what I would do for my application.
 
Top