MySQL Blob Column Jpg Write,read and display
Posted: Sun May 27, 2012 7:46 am
Hi,
Can somebody provide a sample code for writing and reading a jpg file to a blob field in MySQL using FWH Harbour
For writing to Blob filed, I tried
Update the table's blob field with cImageData
To display the Image from the database, I prefer to read the blob field content directly into memory variable (ie without writing the blob contents to hard disk, to create a jpg file) and then display the image on the IMAGE control placed on my Dialog using oImage:LoadFromMemory(cImageData)
For reading and displaying on IMAGE Control, I use the following code.
But nothing displayed.
I have also tried HexToStr() and StrToHex() to write and read from MySQL Blob field but not successful
I have also tried fMimeEnc() and fMimeDec() to write and read from MySQL Blob field but not successful
Searched the forum and could not find any working solution.
TIA
Can somebody provide a sample code for writing and reading a jpg file to a blob field in MySQL using FWH Harbour
For writing to Blob filed, I tried
Code: Select all
cImageData:=MemoRead("D:\Test.Jpg") // Read the Jpj file contents to a variable
cImageData:=cMimeEnc(cImageData)
To display the Image from the database, I prefer to read the blob field content directly into memory variable (ie without writing the blob contents to hard disk, to create a jpg file) and then display the image on the IMAGE control placed on my Dialog using oImage:LoadFromMemory(cImageData)
For reading and displaying on IMAGE Control, I use the following code.
Code: Select all
@ 0, 0 IMAGE oImage SIZE 150, 150 OF oDlg
Code: Select all
cImageData:=oRecSet:Fields("MyBlobColumn"):Value
cImageData:=cMimeDec(cImageData)
oImage:LoadFromMemory(cImageData)
oImage:Refresh()
I have also tried HexToStr() and StrToHex() to write and read from MySQL Blob field but not successful
I have also tried fMimeEnc() and fMimeDec() to write and read from MySQL Blob field but not successful
Searched the forum and could not find any working solution.
TIA