iOS Question The image does not save in the database

karmba_a

Member
Licensed User
Longtime User
The image does not save in the database
What's the solution

31566953fcd14f702e7ec0dee7b900c37afeda57f1d9a020d7f139beeddf9a85d917a159.jpg
 

karmba_a

Member
Licensed User
Longtime User
The image does not save in the database
What's the solution

B4X:
Public Sub BytesToImage(bytes() As Byte) As Bitmap
    Dim In As InputStream
    In.InitializeFromBytesArray(bytes, 0, bytes.Length)
    Dim bmp As Bitmap
    bmp.Initialize2(In)
    Return bmp

End Sub

Sub Button1_Click
    Dim cmd1 As DBCommand
    cmd1.Initialize
    cmd1.Name = "insert_animal"
'   This is not working
    cmd1.Parameters = Array As Object(TextField1.Text, ImageToBytes(ImageView1.Bitmap))
'   This works
'   cmd1.Parameters = Array As Object(TextField1.Text, Bit.InputStreamToBytes(File.OpenInput(File.DirAssets, "smiley.png")))
    reqManager.ExecuteBatch(Array(cmd1), Null)
    GetAnimal(TextField1.Text)
    ActivityIndicator1.Visible = True
End Sub

Sub Cam_Complete (Success As Boolean, Image As Bitmap, VideoPath As String)
    Dim p As Phone
    If Success Then
        If Image.IsInitialized Then
            vv.View.Visible = False
            ImageView1.Bitmap = Image
            'p.AddImageToAlbum(Image)
        Else
            vv.View.Visible = True
            vv.LoadVideo(VideoPath, "")
            Log(p.AddVideoToAlbum(VideoPath, ""))
            timer1.Enabled = True
        End If
    End If
End Sub

B4X:
HandleJob: 5
Tag: select_animal, Columns: 3, Rows: 7
name    image    id  
Mahmoud    <B4IArray: 0x14dbb390>    39  
Mubarak    <B4IArray: 0x14d2dfb0>    40  
Mubarak    <B4IArray: 0x14d0f290>    63  
Mubarak    <B4IArray: 0x14df2970>    64  
Mubarak    <B4IArray: 0x14d2e1c0>    65  
Mubarak    <B4IArray: 0x14d280e0>    66  
Class (b4i_httpjob) instance released.
Error response: , status code: 500
Error: unknown error
Class (b4i_httpjob) instance released.
 
Last edited:
Upvote 0

karmba_a

Member
Licensed User
Longtime User
B4X:
(MysqlDataTruncation) com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'image' at row 1
Command: batch (size=1), took: 740ms, client=10.4.0.10
Command: query: select_animal, took: 60ms, client=10.4.0.10
 
Upvote 0
Top