How to print a image stored in a blob of a MySql table?

153 views
Skip to first unread message

Bingen

unread,
Feb 9, 2012, 5:07:30 AM2/9/12
to FastReport for [x]Harbour, Alaska Xbase++, Visual FoxPro
I have JPG images stored in a blob of a MySql table, and I put a Image
(TFrxPictureView) over FR3 design, I set the Dataset and DataField
correctly but nothing appears.

What's the problem?

I've try yet with LoadImageFromHbVar but I don't have results.

Any other way.

Thanks.

Bingen

unread,
Feb 10, 2012, 3:19:22 AM2/10/12
to FastReport for [x]Harbour, Alaska Xbase++, Visual FoxPro
I've founded a old response fron Sergey about this, don't run 100% but
with and adjust

Starting with FRH 4.8 use such version of SetXailerDataSet()-
function.

function SetXailerDataSet(oFrManager, cFrAlias, oDataSet)
local cStr:='', x

for x := 1 to oDataSet:FieldCount()
if oDataSet:aFields[x]:nSQLType = 205
cStr+=oDataSet:FieldName(x) + "^b;"
else
cStr+=oDataSet:FieldName(x) + ";"
endif
next

oFrManager:SetUserDataSet(cFrAlias, cStr,;
{||oDataSet:GoTop()}, {||
oDataSet:Skip(1)}, ;
{||oDataSet:Skip(-1)}, {||
oDataSet:Eof()},;
{|cField|
oDataSet:oFieldByName(cField):FieldGet()})
Return Nil


(aFields[x]:nSQLType = 205) is tested with ADO. If in your dataset
binary
field has another nSQLType-value then add it too.

In report simply set DataSet and DataField properties for
TfrxPictureView
object.

My Adjust is

for x := 1 to oDataSet:FieldCount()
if ValType(oDataSet:aFields[x]:nSQLType)="C" .And.
oDataSet:aFields[x]:nSQLType = "BLOB"
cStr+=oDataSet:FieldName(x) + "^b;"
else
cStr+=oDataSet:FieldName(x) + ";"
endif
next

Because nSqlType returns a literal with type of Sql field (may be an
bug on Xailer)

Regards

Spirin Sergey

unread,
Feb 10, 2012, 6:03:35 PM2/10/12
to FastReport for [x]Harbour, Alaska Xbase++, Visual FoxPro
Hello, Bingen,

Ii's need to understand then "we" call :SetWorkArea() then "I" can
call DbStruct() and get all info. When "we" call :SetUserDataSet() "I"
cannot call DbStruct(). So of course, mark blob-memo fields with "^b"
suffix.

---
Sergey Spirin.
FastReport for Xbase-family languages,
http://www.spirins.com
Reply all
Reply to author
Forward
0 new messages