Android Question SQLite Insert/Update BLOB at specific position

Declan

Well-Known Member
Licensed User
Longtime User
Hi, the following code inserts a BLOB:
B4X:
SQL1.ExecNonQuery2("INSERT INTO table2 VALUES('smiley', ?)", Array As Object(Buffer))
However, I have a table that has 6 fields: id, img1, img2, img3, img4, img5

How can I insert the BLOB into a specific field, say "img3"?
Also, what would the syntax be to UPDATE / SET a BLOB in a specific field?

My code is:
B4X:
    Dim InputStream1 As InputStream
    InputStream1 = File.OpenInput(File.DirAssets, "yelloe icone empty - copy.png")
    Dim OutputStream1 As OutputStream
    OutputStream1.InitializeToBytesArray(1000)
    File.Copy2(InputStream1, OutputStream1)
    Dim Buffer() As Byte 'declares an empty array
    Buffer = OutputStream1.ToBytesArray
    'write the image to the database at position "img3"
 

Lahksman

Active Member
Licensed User
Longtime User
For the insert it would be something like this:
B4X:
SQL1.ExecNonQuery2("INSERT INTO table2 (id, img3) VALUES ('1',?)", Arry as Object(Buffer))

For the UPDATE it would be like this:
B4X:
SQL1.ExecNonQuery2("UPDATE table2 SET img3 = ? WHERE id = 1", Arry as Object(Buffer))
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
Many thanks that works.

However, when I attempt to load the BLOB, I get the following error:
B4X:
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference

My code is:
B4X:
Sub LoadPartnersIcons
    Dim Cursor1 As Cursor
    Cursor1 = Starter.SQL0.ExecQuery("SELECT partner1img FROM partners")
    Cursor1.Position = 0
    Dim Buffer() As Byte
    Buffer = Cursor1.GetBlob("partner1img")
    Dim InputStream1 As InputStream
    InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
    Dim Bitmap1 As Bitmap
    Bitmap1.Initialize2(InputStream1)
    InputStream1.Close
    imgPartner1.SetBackgroundImage(Bitmap1)
    Cursor1.Close
   
   
    Dim Cursor1 As Cursor
    Cursor1 = Starter.SQL0.ExecQuery("SELECT partner2img FROM partners")
    Cursor1.Position = 0
    Dim Buffer() As Byte
    Buffer = Cursor1.GetBlob("partner2img")
    Dim InputStream1 As InputStream
    InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length) ' I get the error here
    Dim Bitmap1 As Bitmap
    Bitmap1.Initialize2(InputStream1)
    InputStream1.Close
    imgPartner2.SetBackgroundImage(Bitmap1)
    Cursor1.Close
   
    Dim Cursor1 As Cursor
    Cursor1 = Starter.SQL0.ExecQuery("SELECT partner3img FROM partners")
    Cursor1.Position = 0
    Dim Buffer() As Byte 'declare an empty byte array
    Buffer = Cursor1.GetBlob("partner3img")
    Dim InputStream1 As InputStream
    InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
    Dim Bitmap1 As Bitmap
    Bitmap1.Initialize2(InputStream1)
    InputStream1.Close
    imgPartner3.SetBackgroundImage(Bitmap1)
    Cursor1.Close
   
    Dim Cursor1 As Cursor
    Cursor1 = Starter.SQL0.ExecQuery("SELECT partner4img FROM partners")
    Cursor1.Position = 0
    Dim Buffer() As Byte 'declare an empty byte array
    Buffer = Cursor1.GetBlob("partner4img")
    Dim InputStream1 As InputStream
    InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
    Dim Bitmap1 As Bitmap
    Bitmap1.Initialize2(InputStream1)
    InputStream1.Close
    imgPartner4.SetBackgroundImage(Bitmap1)
    Cursor1.Close
   
    Dim Cursor1 As Cursor
    Cursor1 = Starter.SQL0.ExecQuery("SELECT partner5img FROM partners")
    Cursor1.Position = 0
    Dim Buffer() As Byte 'declare an empty byte array
    Buffer = Cursor1.GetBlob("partner5img")
    Dim InputStream1 As InputStream
    InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
    Dim Bitmap1 As Bitmap
    Bitmap1.Initialize2(InputStream1)
    InputStream1.Close
    imgPartner5.SetBackgroundImage(Bitmap1)
    Cursor1.Close

End Sub
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
Yes, I am loading the table with this code:
B4X:
Sub LoadPartnersDummy
    'convert the image file to a bytes array
    Dim InputStream1 As InputStream
    InputStream1 = File.OpenInput(File.DirAssets, "yelloe icone empty - copy.png")
    Dim OutputStream1 As OutputStream
    OutputStream1.InitializeToBytesArray(1000)
    File.Copy2(InputStream1, OutputStream1)
    Dim Buffer() As Byte 'declares an empty array
    Buffer = OutputStream1.ToBytesArray
    Starter.SQL0.ExecNonQuery2("INSERT INTO partners (id, partner1img) VALUES ('1',?)", Array As Object(Buffer))
  
    'convert the image file to a bytes array
    Dim InputStream1 As InputStream
    InputStream1 = File.OpenInput(File.DirAssets, "greyicon empty.png")
    Dim OutputStream1 As OutputStream
    OutputStream1.InitializeToBytesArray(1000)
    File.Copy2(InputStream1, OutputStream1)
    Dim Buffer() As Byte 'declares an empty array
    Buffer = OutputStream1.ToBytesArray
    'write the image to the database
    Starter.SQL0.ExecNonQuery2("INSERT INTO partners (id, partner2img) VALUES ('1',?)", Array As Object(Buffer))
  
    'convert the image file to a bytes array
    Dim InputStream1 As InputStream
    InputStream1 = File.OpenInput(File.DirAssets, "green icon empty.png")
    Dim OutputStream1 As OutputStream
    OutputStream1.InitializeToBytesArray(1000)
    File.Copy2(InputStream1, OutputStream1)
    Dim Buffer() As Byte 'declares an empty array
    Buffer = OutputStream1.ToBytesArray
    'write the image to the database
    Starter.SQL0.ExecNonQuery2("INSERT INTO partners (id, partner3img) VALUES ('1',?)", Array As Object(Buffer))
  
    'convert the image file to a bytes array
    Dim InputStream1 As InputStream
    InputStream1 = File.OpenInput(File.DirAssets, "yelloe icone empty - copy.png")
    Dim OutputStream1 As OutputStream
    OutputStream1.InitializeToBytesArray(1000)
    File.Copy2(InputStream1, OutputStream1)
    Dim Buffer() As Byte 'declares an empty array
    Buffer = OutputStream1.ToBytesArray
    'write the image to the database
    Starter.SQL0.ExecNonQuery2("INSERT INTO partners (id, partner4img) VALUES ('1',?)", Array As Object(Buffer))
  
    'convert the image file to a bytes array
    Dim InputStream1 As InputStream
    InputStream1 = File.OpenInput(File.DirAssets, "rediconempty - copy.png")
    Dim OutputStream1 As OutputStream
    OutputStream1.InitializeToBytesArray(1000)
    File.Copy2(InputStream1, OutputStream1)
    Dim Buffer() As Byte 'declares an empty array
    Buffer = OutputStream1.ToBytesArray
    'write the image to the database
    Starter.SQL0.ExecNonQuery2("INSERT INTO partners (id, partner5img) VALUES ('1',?)", Array As Object(Buffer))
  
End Sub

If I "walk Through" the above code in debug mode, all instances of "Buffer" has data, so I assume that all fields are being written.
 
Last edited:
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
Here is the full error message:
B4X:
** Service (starter) Create **
JAVA [Initialize] eventname = objWFI
[isConnectedToInternet]true
** Service (starter) Start **
[objWFI_onInitialized]
Ping Host:197.189.232.202
Ping:0
Network WIFI connected
WifiAvailable:true
WifiConnected:true
Ping Host:197.189.232.202
Ping:0
MobileAvailable:true
BroadcastReceiver::onReceive::android.net.conn.CONNECTIVITY_CHANGE
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (playsplash) Create, isFirst = true **
** Activity (playsplash) Resume **
Playing completed
---- AppUpdating.ReadCurVN
    Current Version: 1.01
Unexpected event (missing RaiseSynchronousEvents): update_updatecomplete
Check the unfiltered logs for the full stack trace.
---- AppUpdating.ReadWebVN
** Activity (playsplash) Pause, UserClosed = false **
** Activity (menu) Create, isFirst = true **
Error occurred on line: 84 (Menu)
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
    at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:589)
    at anywheresoftware.b4a.shell.Shell.getField(Shell.java:668)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:349)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
    at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:259)
    at com.rob.ebuki.menu._loadpartnersicons(menu.java:402)
    at com.rob.ebuki.menu._activity_create(menu.java:390)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:703)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:340)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at com.rob.ebuki.menu.afterFirstLayout(menu.java:102)
    at com.rob.ebuki.menu.access$000(menu.java:17)
    at com.rob.ebuki.menu$WaitForLayout.run(menu.java:80)
    at android.os.Handler.handleCallback(Handler.java:815)
    at android.os.Handler.dispatchMessage(Handler.java:104)
    at android.os.Looper.loop(Looper.java:194)
    at android.app.ActivityThread.main(ActivityThread.java:5637)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
** Activity (menu) Resume **
 
Upvote 0

Lahksman

Active Member
Licensed User
Longtime User
Right now you are insterting 5 different records, 1 record for each image.
You need to insert the 5 different image in the same record. So your insert statement should include all 5 images.

Could you upload your project? That way I can provide you with a working example.
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
Project is too big to upload - this is just a small segment of the entire project.
First I create the table "partners", then I insert the BLOBs with "LoadPartnersDummy":
B4X:
Sub LOCALCreatePartnersTable
    Dim m As Map
    m.Initialize 'clear the map
    m.Put("id", DBUtils.DB_TEXT)
    m.Put("partner1img", DBUtils.DB_BLOB)
    m.Put("partner2img", DBUtils.DB_BLOB)
    m.Put("partner3img", DBUtils.DB_BLOB)
    m.Put("partner4img", DBUtils.DB_BLOB)
    m.Put("partner5img", DBUtils.DB_BLOB)
    DBUtils.CreateTable(Starter.SQL0, "partners", m, "")
    ToastMessageShow("Partners Table Created", False)
    LoadPartnersDummy
End Sub

Sub LoadPartnersDummy
    'convert the image file to a bytes array
    Dim InputStream1 As InputStream
    InputStream1 = File.OpenInput(File.DirAssets, "yelloe icone empty - copy.png")
    Dim OutputStream1 As OutputStream
    OutputStream1.InitializeToBytesArray(1000)
    File.Copy2(InputStream1, OutputStream1)
    Dim Buffer() As Byte 'declares an empty array
    Buffer = OutputStream1.ToBytesArray
    Starter.SQL0.ExecNonQuery2("INSERT INTO partners (id, partner1img) VALUES ('1',?)", Array As Object(Buffer))
   
    'convert the image file to a bytes array
    Dim InputStream1 As InputStream
    InputStream1 = File.OpenInput(File.DirAssets, "greyicon empty.png")
    Dim OutputStream1 As OutputStream
    OutputStream1.InitializeToBytesArray(1000)
    File.Copy2(InputStream1, OutputStream1)
    Dim Buffer() As Byte 'declares an empty array
    Buffer = OutputStream1.ToBytesArray
    'write the image to the database
    Starter.SQL0.ExecNonQuery2("INSERT INTO partners (id, partner2img) VALUES ('1',?)", Array As Object(Buffer))
   
    'convert the image file to a bytes array
    Dim InputStream1 As InputStream
    InputStream1 = File.OpenInput(File.DirAssets, "green icon empty.png")
    Dim OutputStream1 As OutputStream
    OutputStream1.InitializeToBytesArray(1000)
    File.Copy2(InputStream1, OutputStream1)
    Dim Buffer() As Byte 'declares an empty array
    Buffer = OutputStream1.ToBytesArray
    'write the image to the database
    Starter.SQL0.ExecNonQuery2("INSERT INTO partners (id, partner3img) VALUES ('1',?)", Array As Object(Buffer))
   
    'convert the image file to a bytes array
    Dim InputStream1 As InputStream
    InputStream1 = File.OpenInput(File.DirAssets, "yelloe icone empty - copy.png")
    Dim OutputStream1 As OutputStream
    OutputStream1.InitializeToBytesArray(1000)
    File.Copy2(InputStream1, OutputStream1)
    Dim Buffer() As Byte 'declares an empty array
    Buffer = OutputStream1.ToBytesArray
    'write the image to the database
    Starter.SQL0.ExecNonQuery2("INSERT INTO partners (id, partner4img) VALUES ('1',?)", Array As Object(Buffer))
   
    'convert the image file to a bytes array
    Dim InputStream1 As InputStream
    InputStream1 = File.OpenInput(File.DirAssets, "rediconempty - copy.png")
    Dim OutputStream1 As OutputStream
    OutputStream1.InitializeToBytesArray(1000)
    File.Copy2(InputStream1, OutputStream1)
    Dim Buffer() As Byte 'declares an empty array
    Buffer = OutputStream1.ToBytesArray
    'write the image to the database
    Starter.SQL0.ExecNonQuery2("INSERT INTO partners (id, partner5img) VALUES ('1',?)", Array As Object(Buffer))
   
End Sub

Then, from another Module I read the BLOBs to display in in 5 separate ImageView:
B4X:
Sub LoadPartnersIcons
    Dim Cursor1 As Cursor
    Cursor1 = Starter.SQL0.ExecQuery("SELECT partner1img FROM partners")
    Cursor1.Position = 0
    Dim Buffer() As Byte
    Buffer = Cursor1.GetBlob("partner1img")
    Dim InputStream1 As InputStream
    InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
    Dim Bitmap1 As Bitmap
    Bitmap1.Initialize2(InputStream1)
    InputStream1.Close
    imgPartner1.SetBackgroundImage(Bitmap1)
    Cursor1.Close
   
    Dim Cursor1 As Cursor
    Cursor1 = Starter.SQL0.ExecQuery("SELECT partner2img FROM partners")
    Cursor1.Position = 0
    Dim Buffer() As Byte
    Buffer = Cursor1.GetBlob("partner2img")
    Dim InputStream1 As InputStream
    InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length) ' I get the error here
    Dim Bitmap1 As Bitmap
    Bitmap1.Initialize2(InputStream1)
    InputStream1.Close
    imgPartner2.SetBackgroundImage(Bitmap1)
    Cursor1.Close
   
    Dim Cursor1 As Cursor
    Cursor1 = Starter.SQL0.ExecQuery("SELECT partner3img FROM partners")
    Cursor1.Position = 0
    Dim Buffer() As Byte 'declare an empty byte array
    Buffer = Cursor1.GetBlob("partner3img")
    Dim InputStream1 As InputStream
    InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
    Dim Bitmap1 As Bitmap
    Bitmap1.Initialize2(InputStream1)
    InputStream1.Close
    imgPartner3.SetBackgroundImage(Bitmap1)
    Cursor1.Close
   
    Dim Cursor1 As Cursor
    Cursor1 = Starter.SQL0.ExecQuery("SELECT partner4img FROM partners")
    Cursor1.Position = 0
    Dim Buffer() As Byte 'declare an empty byte array
    Buffer = Cursor1.GetBlob("partner4img")
    Dim InputStream1 As InputStream
    InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
    Dim Bitmap1 As Bitmap
    Bitmap1.Initialize2(InputStream1)
    InputStream1.Close
    imgPartner4.SetBackgroundImage(Bitmap1)
    Cursor1.Close
   
    Dim Cursor1 As Cursor
    Cursor1 = Starter.SQL0.ExecQuery("SELECT partner5img FROM partners")
    Cursor1.Position = 0
    Dim Buffer() As Byte 'declare an empty byte array
    Buffer = Cursor1.GetBlob("partner5img")
    Dim InputStream1 As InputStream
    InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
    Dim Bitmap1 As Bitmap
    Bitmap1.Initialize2(InputStream1)
    InputStream1.Close
    imgPartner5.SetBackgroundImage(Bitmap1)
    Cursor1.Close

End Sub

At a later time, I will use RDC to read BLOBs from a MySQL database and UPDATE the BLOBs in the "partners" table.
 
Upvote 0

Lahksman

Active Member
Licensed User
Longtime User
Following code is a possible solution (although it could probably be written better/cleaner) to be able to insert all 5 images at once.
B4X:
Sub LoadPartnersDummy
    dim buffer1(), buffer2(), buffer3(), buffer4(), buffer5() as byte
    Dim InputStream1 As InputStream
    InputStream1 = File.OpenInput(File.DirAssets, "yelloe icone empty - copy.png")
    buffer1() = CreateBuffer(inputStream1)
    InputStream1 = File.OpenInput(File.DirAssets, "greyicon empty.png")
    buffer2() = CreateBuffer(inputStream1)
    InputStream1 = File.OpenInput(File.DirAssets, "green icon empty.png")
    buffer3() = CreateBuffer(inputStream1)
    InputStream1 = File.OpenInput(File.DirAssets, "yelloe icone empty - copy.png")
    buffer4() = CreateBuffer(inputStream1)
    InputStream1 = File.OpenInput(File.DirAssets, "rediconempty - copy.png")
    buffer5() = CreateBuffer(inputStream1)
    Starter.SQL0.ExecNonQuery2("INSERT INTO partners (id, partner1img, partner2img, partner3img, partner4img, partner5img) VALUES ('1',?,?,?,?,?)", Array As Object(Buffer1, Buffer2, Buffer3, Buffer4, Buffer5))
end Sub

Sub CreateBuffer(input as InputStream) as Buffer()
    Dim Output as OutputStream
    OutputStream1.InitializeToBytesArray(1000)
    File.Copy2(input, Output)
    Dim Buffer() As Byte 'declares an empty array
    Buffer = Output.ToBytesArray
    return Buffer()
end sub

This is not tested, quickly wrote it with notepad++
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
I get a compile error:
B4X:
Error description: Unknown type: buffer
Are you missing a library reference?
Sub CreateBuffer(input As InputStream) As Buffer()
Here:
B4X:
Sub CreateBuffer(input As InputStream) As Buffer()
    Dim Output As OutputStream
    input.InitializeToBytesArray(1000)
    File.Copy2(input, Output)
    Dim Buffer() As Byte 'declares an empty array
    Buffer = Output.ToBytesArray
    Return Buffer()
End Sub
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
Now have errors:
Unused Variable:
B4X:
Dim InputStream1 As InputStream

Missing parameter:
B4X:
buffer1() = CreateBuffer(InputStream1)

Compile error:
B4X:
Error compiling program.
Error description: Unknown member: initializetobytesarray
Occurred on line: 530
    input.InitializeToBytesArray(1000)
Word: initializetobytesarray
Here:
B4X:
input.InitializeToBytesArray(1000)
 
Upvote 0

Lahksman

Active Member
Licensed User
Longtime User
B4X:
buffer1() = CreateBuffer(InputStream1)
should be
B4X:
buffer1 = CreateBuffer(InputStream1)

and
B4X:
input.InitializeToBytesArray(1000)
should be
B4X:
output.InitializeToBytesArray(1000)
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
I am now attempting to UPDATE my SQLite table from data received via RDC connection to my remote MySQL database.
I receive the following error:
B4X:
java.lang.NumberFormatException: Invalid double: "null"
When I run this code in the JobDone event:
B4X:
                If result.Tag = "get_partners" Then
                    ProgressDialogHide
                        For Each records() As Object In result.Rows
                                Dim buffer1(), buffer2(), buffer3(), buffer4(), buffer5() As Byte
                                Dim InputStream1 As InputStream
                                InputStream1 = records(result.Columns.Get("partner1img")) <-- ERROR
                                buffer1 = CreateBuffer(InputStream1)
                                InputStream1 = records(result.Columns.Get("partner2img"))
                                buffer2 = CreateBuffer(InputStream1)
                                InputStream1 = records(result.Columns.Get("partner3img"))
                                buffer3 = CreateBuffer(InputStream1)
                                InputStream1 = records(result.Columns.Get("partner4img"))
                                buffer4 = CreateBuffer(InputStream1)
                                InputStream1 = records(result.Columns.Get("partner5img"))
                                buffer5 = CreateBuffer(InputStream1)
                                Starter.SQL0.ExecNonQuery2("UPDATE partners SET id = ?, SET partner1img = ?, SET partner2img = ?, SET partner3img = ?, SET partner4img = ?, SET partner5img = ? WHERE id = 1 VALUES ('1',?,?,?,?,?)", Array As Object(buffer1, buffer2, buffer3, buffer4, buffer5))
                        Next
                End If
The CreateBuffer Sub:
B4X:
Sub CreateBuffer(input As InputStream) As Byte()
    Dim Output As OutputStream
    Output.InitializeToBytesArray(1000)
    File.Copy2(input, Output)
    Dim Buffer() As Byte 'declares an empty array
    Buffer = Output.ToBytesArray
    Return Buffer
End Sub
 
Upvote 0

Lahksman

Active Member
Licensed User
Longtime User
I can only guess without more information.
But it seems that the problem is within the resultset, does it contain any data? Try to add some logging to see if result is getting filled properly.
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
Yes, I am getting BLOB data from the server, as seen in the Log:
B4X:
HandleJob: 14
Tag: get_partners, Columns: 6, Rows: 1
id    partner1image    partner2image    partner3image    partner4image    partner5image   
1    [B@1cbdb9a6    [B@7bccfe7    [B@6671794    [B@338c523d    [B@bfbca32   
Error occurred on line: 150 (Registration)
java.lang.NumberFormatException: Invalid double: "null"
 
Upvote 0

Lahksman

Active Member
Licensed User
Longtime User
I haven't got any experience with blobs.
But if you are transferring data from an mysql blob to an sqllite blob, is it still necesary to convert it?
Couldn't you just say
B4X:
buffer1 = records(result.Columns.Get("partner1img"))
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
Hi, got it sorted with:
B4X:
                If result.Tag = "get_partners" Then
                    ProgressDialogHide
                        For Each records() As Object In result.Rows
                                Dim buffer1(), buffer2(), buffer3(), buffer4(), buffer5() As Byte
                                buffer1 = records(1)
                                buffer2 = records(2)
                                buffer3 = records(3)
                                buffer4 = records(4)
                                buffer5 = records(5)
                                Starter.SQL0.ExecNonQuery2("UPDATE partners SET partner1img = ?,partner2img = ?,partner3img = ?,partner4img = ?,partner5img = ? WHERE id = 1", Array As Object(buffer1, buffer2, buffer3, buffer4, buffer5))
                        Next
                End If
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…