tsteward Well-Known Member Licensed User Longtime User Nov 23, 2014 #1 I want to save the data in a BLOB field to a binary file but don't know how. My failed code Code: Copy Dim dumpdata As ResultSet = sql1.ExecQuery("SELECT * FROM BINFiles WHERE FileID = '1'") Do While dumpdata.NextRow File.WriteString(File.DirApp,"testdump.bin",dumpdata.GetBlob("data")) Loop dumpdata.Close
I want to save the data in a BLOB field to a binary file but don't know how. My failed code Code: Copy Dim dumpdata As ResultSet = sql1.ExecQuery("SELECT * FROM BINFiles WHERE FileID = '1'") Do While dumpdata.NextRow File.WriteString(File.DirApp,"testdump.bin",dumpdata.GetBlob("data")) Loop dumpdata.Close
Erel B4X founder Staff member Licensed User Longtime User Nov 23, 2014 #2 You cannot use WriteString with binary data. Do you assume that there is a single matching result? Otherwise your code will overwrite the file. Code: Copy Dim b() As Byte = dumpData.GetBlob(...) Dim out As OutputStream = File.OpenOutput(File.DirApp,"testdump.bin") out.WriteBytes(b, 0, b.Length) out.Close Upvote 0
You cannot use WriteString with binary data. Do you assume that there is a single matching result? Otherwise your code will overwrite the file. Code: Copy Dim b() As Byte = dumpData.GetBlob(...) Dim out As OutputStream = File.OpenOutput(File.DirApp,"testdump.bin") out.WriteBytes(b, 0, b.Length) out.Close
tsteward Well-Known Member Licensed User Longtime User Nov 23, 2014 #3 Thank Erel, Yes I know there is a single match result. This is also just test code to see if my idea will work. Upvote 0
Thank Erel, Yes I know there is a single match result. This is also just test code to see if my idea will work.