Android Question Error when running "InsertMaps"

rkmoray

Active Member
Licensed User
Longtime User
Inn my app,I have the following code after I initialize a db
B4X:
DBUtils.CreateTable(sql, "tblConfig", CreateMap("ID": DBUtils.DB_TEXT, "Value": DBUtils.DB_TEXT), "")
    Dim row As Map=CreateMap("ID":"IPAddress","Value":"192.168.0.180")
    DBUtils.InsertMaps(sql,"tblConfig",row)

But then I get the following error and I don't know why
*** Service (starter) Create ***
CreateTable: CREATE TABLE IF NOT EXISTS [tblConfig] ([ID] TEXT, [Value] TEXT)
Error occurred on line: 126 (DBUtils)
java.lang.ClassCastException: anywheresoftware.b4a.objects.collections.Map$MyMap cannot be cast to java.util.List
at anywheresoftware.b4a.objects.collections.List.getSize(List.java:129)
at java.lang.reflect.Method.invoke(Native Method)
 

DonManfred

Expert
Licensed User
Longtime User
Check this code. Think over what is different to your code.
Also note the onlinehelp for InsertMaps

B4X:
Dim ListOfMaps As List
    ListOfMaps.Initialize
    For i = 1 To 40
        Dim m As Map
        m.Initialize
        m.Put("Id", Id)
        m.Put("First Name", "John")
        m.Put("Last Name", "Smith" & i)
        ListOfMaps.Add(m)
    Next
    DBUtils.InsertMaps(SQL, "Students", ListOfMaps)
 
Upvote 0
Top