Android Question Error getting image from table

Makumbi

Well-Known Member
Licensed User
Please help i have photos that already stored on my SQLserver database as bytes in use. i wanted to insert them in a table in my app then later read them using the app but iam getting the error below please help
B4X:
Logger connected to: emulator-5554
--------- beginning of main
--------- beginning of system
** Receiver (tracker) OnReceive **
Cannot start from a receiver in debug mode.
Copying updated assets files (35)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
ExecuteHtml: SELECT DISTINCT Names,Class || Stream As CS,Amount As Balance FROM Balances
6
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
** Service (httputils2service) Start **
[{"Account":"05-00001","Name":"BUGEMBE YASIN ismail","Stream":"A","Category":"Active","Country":"S2","Froms":"\/Date(1545512400000)\/","Tos":"\/Date(1554152400000)\/"}]
(JSONTokener)  at character 0 of [{"Account":"05-00001","Name":"BUGEMBE YASIN ismail","Stream":"A","Category":"Active","Country":"S2","Froms":"\/Date(1545512400000)\/","Tos":"\/Date(1554152400000)\/"}]
Name: BUGEMBE YASIN ismail
Category: Active
Froms: /Date(1545512400000)/
Tos: /Date(1554152400000)/
12/23/2018
23/12/2018
02/04/2019
02/04/2019
[{"Account":"05-00001","Name":"BUGEMBE YASIN ismail","Stream":"A","Category":"Active","Country":"S2","Froms":"\/Date(1545512400000)\/","Tos":"\/Date(1554152400000)\/"}]
[{"Account":"05-00001","Name":"BUGEMBE YASIN ismail","Stream":"A","Category":"Active","Country":"S2","Froms":"\/Date(1545512400000)\/","Tos":"\/Date(1554152400000)\/"}]
[{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"MATHEMATICS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":1},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"BIOLOGY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":2},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"COMPUTER","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":3},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"CHEMISTRY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":4},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"ENTREPRENUERSHIP","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":5},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"HISTORY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":6},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"ADD-MATHS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":7},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"FINE-ART","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":8},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"CRE","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":9},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"PHYSICS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":10},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"TOTAL MARKS","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":0,"autofield":11},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"AVERAGE","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":0,"autofield":12},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"POSITIONSTREAM","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":1,"autofield":13},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"OUTOF","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":2,"autofield":14},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"GEOGRAPHY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":15}]
(JSONTokener)  at character 0 of [{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"MATHEMATICS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":1},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"BIOLOGY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":2},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"COMPUTER","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":3},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"CHEMISTRY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":4},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"ENTREPRENUERSHIP","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":5},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"HISTORY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":6},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"ADD-MATHS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":7},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"FINE-ART","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":8},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"CRE","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":9},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"PHYSICS","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":10},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"TOTAL MARKS","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":0,"autofield":11},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"AVERAGE","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":0,"autofield":12},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"POSITIONSTREAM","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":1,"autofield":13},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"OUTOF","Mid":null,"Ends":null,"Grade":null,"Term":"TERM1","Years":"2019","Total":2,"autofield":14},{"Account":"05-00001","class":"S2","Stream":"A","Names":"BUGEMBE YASIN ismail","Subject":"GEOGRAPHY","Mid":null,"Ends":null,"Grade":"F9","Term":"TERM1","Years":"2019","Total":0,"autofield":15}]
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: MATHEMATICS
Total: 0
atk: 1
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: BIOLOGY
Total: 0
atk: 2
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: COMPUTER
Total: 0
atk: 3
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: CHEMISTRY
Total: 0
atk: 4
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: ENTREPRENUERSHIP
Total: 0
atk: 5
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: HISTORY
Total: 0
atk: 6
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: ADD-MATHS
Total: 0
atk: 7
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: FINE-ART
Total: 0
atk: 8
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: CRE
Total: 0
atk: 9
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: PHYSICS
Total: 0
atk: 10
Account: 05-00001
Grade: null
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: TOTAL MARKS
Total: 0
atk: 11
Account: 05-00001
Grade: null
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: AVERAGE
Total: 0
atk: 12
Account: 05-00001
Grade: null
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: POSITIONSTREAM
Total: 1
atk: 13
Account: 05-00001
Grade: null
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: OUTOF
Total: 2
atk: 14
Account: 05-00001
Grade: F9
Mids: null
Ends: null
Stream: A
Names: BUGEMBE YASIN ismail
Class: S2
Term: TERM1
Subject: GEOGRAPHY
Total: 0
atk: 15
** Activity (main) Pause, UserClosed = false **
** Activity (eventsdata) Create, isFirst = true **
ExecuteHtml: SELECT Distinct Events,Class || Stream As CS,Dates FROM Eventsinfo
** Activity (eventsdata) Resume **
** Activity (eventsdata) Pause, UserClosed = true **
** Activity (main) Resume **
ExecuteHtml: SELECT DISTINCT Names,Class || Stream As CS,Amount As Balance FROM Balances
6
** Activity (main) Pause, UserClosed = false **
** Activity (linkupdates) Create, isFirst = true **
** Activity (linkupdates) Resume **
[{"Account":"05-00001","Name":"BUGEMBE YASIN ismail","Stream":"A","Category":"Active","Country":"S2","Froms":"\/Date(1545512400000)\/","Tos":"\/Date(1554152400000)\/"}]
(JSONTokener)  at character 0 of [{"Account":"05-00001","Name":"BUGEMBE YASIN ismail","Stream":"A","Category":"Active","Country":"S2","Froms":"\/Date(1545512400000)\/","Tos":"\/Date(1554152400000)\/"}]
Account: 05-00001
Name: BUGEMBE YASIN ismail
Category: Active
(JSONTokener)  at character 0 of [{"CustomerId":"05-00001","Name":"BUGEMBE YASIN ismail","Country":"S2","stream":"A","Photo":[255,216,255,224,0,16,74,70,73,70,0,1,1,1,0,96,0,96,0,0,255,219,0,67,0,3,2,2,3,2,2,3,3,3,3,4,3,3,4,5,8,5,5,4,4,5,10,7,7,6,8,12,10,12,12,11,10,11,11,13,14,18,16,13,14,17,14,11,11,16,22,16,17,19,20,21,21,21,12,15,23,24,22,20,24,18,20,21,20,255,219,0,67,1,3,4,4,5,4,5,9,5,5,9,20,13,11,13,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,255,192,0,17,8,0,192,0,149,3,1,34,0,2,17,1,3,17,1,255,196,0,31,0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,255,196,0,181,16,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125,1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250,255,196,0,31,1,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,255,196,0,181,17,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119,0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250,255,218,0,12,3,1,0,2,17,3,17,0,63,0,251,160,47,235,70,207,148,138,95,78,123,208,192,149,62,245,246,167,8,173,31,202,49,70,206,41,202,196,12,245,167,31,155,7,20,134,71,26,129,131,239,79,227,116,126,184,111,233,74,160,243,199,122,38,202,152,190,166,144,10,171,249,83,153,113,219,181,53,72,227,252,40,121,20,21,206,127,42,64,6,61,217,199,6,148,71,134,207,106,65,32,28,131,79,19,14,56,38,129,13,85,235,207,122,114,142,105,119,47,80,13,35,56,94,113,72,161,248,206,72,166,237,220,71,165,30,119,79,148,224,211,149,199,93,167,243,164,22,184,58,226,69,169,99,143,25,166,253,226,14,58,84,161,134,122,84,182,90,67,17,177,27,140,251,214,117,211,22,147,138,208,147,10,199,211,21,157,203,19,199,57,171,135,112,145,58,199,158,244,83,227,95,151,158,180,83,184,138,104,7,3,173,79,180,5,233,85,87,57,230,164,223,242,243,210,181,49,185,97,118,231,3,166,41,127,134,162,86,238,41,225,190,90,155,5,199,2,112,113,214,150,111,153,99,56,228,62,63,67,77,62,195,20,179,156,42,158,159,56,63,161,169,41,49,70,41,36,80,64,172,159,22,120,187,71,240,78,141,54,171,174,106,17,105,214,48,253,233,165,61,79,160,29,73,62,131,154,249,23,226,167,237,151,175,248,130,105,180,255,0,2,217,157,42,203,5,127,180,174,80,61,195,245,25,85,229,83,241,201,250,26,198,165,72,211,214,76,214,20,229,83,100,125,143,125,125,103,165,219,153,238,238,161,181,132,117,146,121,2,47,230,107,158,183,248,159,224,217,165,104,227,241,94,138,238,189,85,117,8,137,31,248,245,126,110,106,240,248,151,198,23,159,109,214,181,75,141,74,233,191,229,165,237,195,72,64,244,25,206,7,176,226,171,207,224,211,30,29,165,95,162,142,43,130,88,216,167,162,59,99,132,151,83,245,66,214,242,222,242,5,150,218,120,238,34,110,146,68,225,148,254,34,167,102,202,244,205,126,85,232,186,191,136,124,15,124,183,122,30,175,115,167,206,188,134,183,148,198,9,247,3,130,49,198,15,21,244,239,193,191,219,53,231,158,219,72,241,244,2,221,216,136,211,90,129,112,132,244,30,106,14,158,236,188,123,14,181,181,60,85,58,142,207,66,42,97,106,65,93,43,159,92,199,134,81,75,198,240,59,84,22,179,199,117,12,115,193,42,77,4,170,25,36,140,134,86,7,144,65,29,69,8
Message longer than Log limit (4000). Message was truncated.
Account: 05-00001
Name: BUGEMBE YASIN ismail
Class: null
Stream: null
Photo: [255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 1, 1, 0, 96, 0, 96, 0, 0, 255, 219, 0, 67, 0, 3, 2, 2, 3, 2, 2, 3, 3, 3, 3, 4, 3, 3, 4, 5, 8, 5, 5, 4, 4, 5, 10, 7, 7, 6, 8, 12, 10, 12, 12, 11, 10, 11, 11, 13, 14, 18, 16, 13, 14, 17, 14, 11, 11, 16, 22, 16, 17, 19, 20, 21, 21, 21, 12, 15, 23, 24, 22, 20, 24, 18, 20, 21, 20, 255, 219, 0, 67, 1, 3, 4, 4, 5, 4, 5, 9, 5, 5, 9, 20, 13, 11, 13, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 255, 192, 0, 17, 8, 0, 192, 0, 149, 3, 1, 34, 0, 2, 17, 1, 3, 17, 1, 255, 196, 0, 31, 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 255, 196, 0, 181, 16, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125, 1, 2, 3, 0, 4, 17, 5, 18, 33, 49, 65, 6, 19, 81, 97, 7, 34, 113, 20, 50, 129, 145, 161, 8, 35, 66, 177, 193, 21, 82, 209, 240, 36, 51, 98, 114, 130, 9, 10, 22, 23, 24, 25, 26, 37, 38, 39, 40, 41, 42, 52, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, 131, 132, 133, 134, 135, 136, 137, 138, 146, 147, 148, 149, 150, 151, 152, 153, 154, 162, 163, 164, 165, 166, 167, 168, 169, 170, 178, 179, 180, 181, 182, 183, 184, 185, 186, 194, 195, 196, 197, 198, 199, 200, 201, 202, 210, 211, 212, 213, 214, 215, 216, 217, 218, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 255, 196, 0, 31, 1, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 255, 196, 0, 181, 17, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119, 0, 1, 2, 3, 17, 4, 5, 33, 49, 6, 18, 65, 81, 7, 97, 113, 19, 34, 50, 129, 8, 20, 66, 145, 161, 177, 193, 9, 35, 51, 82, 240, 21, 98, 114, 209, 10, 22, 36, 52, 225, 37, 241, 23, 24, 25, 26, 38, 39, 40, 41, 42, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, 130, 131, 132, 133, 134, 135, 136, 137, 138, 146, 147, 148, 149, 150, 151, 152, 153, 154, 162, 163, 164, 165, 166, 167, 168, 169, 170, 178, 179, 180, 181, 182, 183, 184, 185, 186, 194, 195, 196, 197, 198, 199, 200, 201, 202, 210, 211, 212, 213, 214, 215, 216, 217, 218, 226, 227, 228, 229, 230, 231, 232, 233, 234, 242, 243, 244, 245, 246, 247, 248, 249, 250, 255, 218, 0, 12, 3, 1, 0, 2, 17, 3, 17, 0, 63, 0, 251, 160, 47, 235, 70, 207, 148, 138, 95, 78, 123, 208, 192, 149, 62, 245, 246, 167, 8, 173, 31, 202, 49, 70, 206, 41, 202, 196, 12, 245, 167, 31, 155, 7, 20, 134, 71, 26, 129, 131, 239, 79, 227, 116, 126, 184, 111, 233, 74, 160, 243, 199, 122, 38, 202, 152, 190, 166, 144, 10, 171, 249, 83, 153, 113, 219, 181, 53, 72, 227, 252, 40, 121, 20, 21, 206, 127, 42, 64, 6, 61, 217, 199, 6, 148, 71, 134, 207, 106, 65, 32, 28, 131, 79, 19, 14, 56, 38, 129, 13, 85, 235, 207, 122, 114, 142, 105, 119, 47, 80, 13, 35, 56, 94, 113, 72, 161, 248, 206, 72, 166, 237, 220, 71, 165, 30, 119, 79, 148, 224, 211, 149, 199, 93, 167, 243, 164, 22, 184, 58, 226, 69, 169, 99, 143, 25, 166, 253, 226, 14, 58, 84, 161, 134, 122, 84, 182, 90, 67, 17, 177, 27, 140, 251, 214, 117, 211, 22, 147, 138, 208, 147, 10, 199, 211, 21, 157, 203, 19, 199, 57, 171, 135, 112, 145, 58, 199, 158, 244, 83, 227, 95, 151, 158, 180, 83, 184, 138, 104, 7, 3, 173, 79, 180, 5, 233, 85, 87, 57, 230, 164, 223, 242, 243, 210, 181, 49, 185, 97, 118, 231, 3, 166, 41, 127, 134, 162, 86, 238, 41, 225, 190, 90, 155, 5, 199, 2, 112, 113, 214, 150, 111, 153, 99, 56, 228, 62, 63, 67, 77, 62, 195, 20, 179, 156, 42, 158, 159, 56, 63, 161, 169, 41, 49, 70, 41, 36, 80, 64, 172, 159, 22, 120, 187, 71, 240, 78, 141, 54, 171, 174, 106, 17, 105, 214, 48, 253, 233, 165, 61, 79, 160, 29, 73, 62, 131, 154, 249, 23, 226, 167, 237, 151, 175, 248, 130, 105, 180, 255, 0, 2, 217, 157, 42, 203, 5, 127, 180, 174, 80, 61, 195, 245, 25, 85, 229, 83, 241, 201, 250, 26, 198,
Message longer than Log limit (4000). Message was truncated.
Error occurred on line: 751 (Linkupdates)
java.lang.IllegalArgumentException: method anywheresoftware.b4a.objects.streams.File.Copy2 argument 1 has type java.io.InputStream, got java.util.ArrayList
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:778)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:358)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
    at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:245)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
    at anywheresoftware.b4a.BA$2.run(BA.java:365)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)

B4X:
cursor1 = Starter.SQL1.ExecQuery("SELECT phone AS Phone,Sex FROM Register")
    If cursor1.RowCount > 0 Then
        '    For i = 0 To cursor1.RowCount - 1
        cursor1.Position =0
        Dim Phoneq As String
        Phoneq = cursor1.Getstring("Phone")
            
        Dim sx As String
        sx = cursor1.Getstring("Sex")
        'Next
    End If
    Dim CustID As String = Phoneq' Customer ID
    Dim jtn As HttpJob
    jtn.Initialize("", Me)
    jtn.Download("http://kccug.com/Generic_Handler_JSON/HandlerVBRegistration.ashx?customerid=" & CustID & "&sx=" & sx)
        
    jtn.GetRequest.Timeout = 10000 ' 10 seconds
    Wait For (jtn) JobDone(jtn As HttpJob)
    If jtn.Success Then ' if job is success (http status code 200)
        Dim RetVal As String
        RetVal = jtn.GetString
        Log(RetVal)
        If jtn.GetString = "[]" Then
            'MsgboxAsync("No Records to Upload Yet for: " & CustID ,"SMIS")
            Return
            
        Else
            
            Dim jpt As JSONParser
            jpt.Initialize(jtn.GetString)
            Log(jpt) ' will pr
            Dim quotes As List = jpt.NextArray
            For Each quot As Map In quotes
                Log("Account: " & quot.Get("Account"))
                Log("Name: " & quot.Get("Name"))
                Log("Category: " & quot.Get("Category"))
                ' add 1 to the ID number to make a new ID field
                Dim CustID As String = quot.Get("Account")
            Next
        End If
                    
        Dim jy As HttpJob
        jy.Initialize("", Me)
        'j.Download("http://kccug.com/WebServicesula/Service.asmx/Get")
        jy.Download("http://kccug.com/Generic_Handler_JSON/HandlerVBPhoto.ashx?customerid=" & CustID)
        'jy.GetRequest.Timeout = 10000 ' 10 seconds
        Wait For (jy) JobDone(jy As HttpJob)
        If jy.Success Then ' if job is success (http status code 200)
            Dim RetVal As String
            RetVal = jy.GetString
            If jy.GetString = "[]" Then
                'MsgboxAsync("No Records to Upload Yet for: " & CustID ,"SMIS")
                Return
            
            Else
            
                Dim jpt As JSONParser
                jpt.Initialize(jy.GetString)
                Log(jpt) ' will pr
                Dim quotes As List = jpt.NextArray
                For Each quot As Map In quotes
                    Log("Account: " & quot.Get("CustomerId"))
                    Log("Name: " & quot.Get("Name"))
                    Log("Class: " & quot.Get("Class"))
                    Log("Stream: " & quot.Get("Stream"))
                    Log("Photo: " & quot.Get("Photo"))
                    Dim InputStream1 As InputStream
                    InputStream1 = quot.Get("Photo")
                    Dim OutputStream1 As OutputStream
                    OutputStream1.InitializeToBytesArray(1000)
                    File.Copy2(InputStream1, OutputStream1)
                    Dim Buffer() As Byte
                    Buffer = OutputStream1.ToBytesArray
                    Starter.SQL1.ExecNonQuery2("INSERT INTO Studentphoto VALUES(?, ?, ?,?,?)", Array As Object(quot.Get("CustomerId"), quot.Get("Name"), quot.Get("Class"),quot.Get("Stream"),Array As Object(Buffer) ))
                    hold=quot.Get("CustomerId")
                    
                    ReadBlob
                Next
            
            End If
        End If
            
    
    Else
        MsgboxAsync("Error Connecting to the Server Please Check Your Internet Connection","Server Error")
        't1.Enabled = False
        Return
    End If
    End Sub
Sub ReadBlob
    Dim cursor1 As Cursor
    'Using ExecQuery2 is safer as it escapes special characters automatically.
    'In this case it doesn't really matter.
    'cursor1 = Starter.SQL1.ExecNonQuery2("SELECT image FROM Studentphoto WHERE Account = ?", Array As String(hold)
    cursor1 = Starter.SQL1.ExecQuery2("SELECT image FROM Studentphoto WHERE Account = ?", Array As String(hold))
    cursor1.Position = 0
    Dim Buffer() As Byte 'declare an empty byte array
    Buffer = cursor1.GetBlob("image")
    Dim InputStream1 As InputStream
    InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
    
    Dim Bitmap1 As Bitmap
    Bitmap1.Initialize2(InputStream1)
    InputStream1.Close
    Activity.SetBackgroundImage(Bitmap1)

End Sub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Tip: You can dim and set a variable in a single line:
B4X:
Dim InputStream1 As InputStream = quote.Get("Photo")
There is even a (very) small performance gain from this.

You will never get an InputStream from a JSON map.
Based on the logs you are saving the image in a very inefficient way. You are storing it as an array of numbers. If you have control over the format then you should change it. If you must use JSON then encode the image bytes with Base64 string encoding.
 
Upvote 0

Makumbi

Well-Known Member
Licensed User
How can i encode the image bytes with Base64 string encoding. please help me with the example thanks inadvance
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Makumbi

Well-Known Member
Licensed User
iam just a new learner trying to solve photo problems because i already have the photos in my sqlserver database
 
Upvote 0
Top