Android Question [SD_SQL] Read image field

vecino

Well-Known Member
Licensed User
Longtime User
Hi, I am reading a table with several fields, the text and numeric fields are no problem.
However, with an image type field I can't read it.
This is the code and the error it shows.
Thank you very much.
B4X:
    Dim cDirImage As String = File.DirInternal
    Dim cFileImage As String = "tempimage.jpg"

    Dim cSql As String = $"select jpgimg from ${MyTable} where id=${iIDregistroActual}"$

    Dim RS As SD_ResultSet = MYSQL.ExecQuery(cSql)     

    Dim img() As Byte = RS.GetBytes("JPGIMG")   '  ERROR on this line. !!!!!!!!!!

    If img.Length>0 Then
        Dim tempimagepath As String = File.Combine(cDirImage,cFileImage)
        File.WriteBytes(cDirImage,cFileImage,img)
        Dim html As String
        html = "<html><body><img src='file://" & tempimagepath & "' /></body></html>"
        Dim webview As WebView = Web
        webview.LoadHtml(html) 
    End If
Error occurred on line: 103 (SD_ResultSet)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
at visor.errores.iofwin.sd_resultset._getbytes(sd_resultset.java:50)
at java.lang.reflect.Method.invoke(Native Method)
...
 

vecino

Well-Known Member
Licensed User
Longtime User
Hi, I have already “solved” it, the problem is that they have deleted the images from the database without informing me.
And I was like crazy writing useless test code.
Thank you.
 
Upvote 0
Top