R rkmoray Active Member Licensed User Longtime User May 4, 2018 #1 Inn my app,I have the following code after I initialize a db Code: 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)
Inn my app,I have the following code after I initialize a db Code: 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 May 4, 2018 #2 Check this code. Think over what is different to your code. Also note the onlinehelp for InsertMaps Code: 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
Check this code. Think over what is different to your code. Also note the onlinehelp for InsertMaps Code: 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)
Erel B4X founder Staff member Licensed User Longtime User May 6, 2018 #3 If you want to insert a single map: Code: DBUtils.InsertMaps(sql,"tblConfig",Array(row)) Upvote 0
R rkmoray Active Member Licensed User Longtime User May 7, 2018 #4 That's perfect, thank you for your help. Upvote 0