Sending a BLOB image from SQLite to SQL server

beni_feld

Member
Licensed User
Longtime User
:sign0085:How can I send a jpg image saved on SQLite as BLOL to SQL Server?
I tried to convert the data to varbinary but always ended with a binary file very similar to a standard jpg file corrupted by many Question marks.

Command.CommandText= "SELECT DocID, Pic FROM Pictures WHERE ActionStatus=1"
Reader.Value = Command.ExecuteReader

sSql="INSERT INTO Pictures (DocID, Pic) VALUES (@id, CAST('@pic' AS varbinary(max)))"

Do While Reader.ReadNextRow = True
sSql1=StrReplace(sSQL,"@id",Reader.Getvalue(0))
Pic()= Reader.GetBytes(1)
iCount=ArrayLen(pic())-1
sStr=converter.StringFrom1Bytes (SQLite.Reader.GetBytes(1),0,iCount)
sStr=StrReplace(sStr,"'","''")
sSql1=StrReplace(sSql1,"@pic",sStr)
msql1.ExecuteQuery(sSql1)
Loop

Corrupted file:
???? JFIF H H ?? *Exif MM * b j ( 1 r 2 ?i ₪ ? H H Adobe Photoshop CS Windows 2005:04:22 01:30:51 t ? & ( . w ..................

JPG file:
״א JFIF H H ב *Exif MM * b j ( 1 r 2 ‡i ₪ ׀ H H Adobe Photoshop CS Windows 2005:04:22 01:30:51 t – & ( . w ..................
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…