Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Insert image to crystal report I have ADO.NET data connection where i'm using

<xs:element name="Drawing" type="xs:byte" minOccurs="0" />

for image field, so how can i use that image byte data to display image in my crystal reports 2013. I'm not using any backend coding because there's possible many images in that retrieved data, Here's my data structure of table "Drawing" is image field of data which i have stored as byte enter image description here

i'm using image contained report as sub report

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
180 views
Welcome To Ask or Share your Answers For Others

1 Answer

I am not sure if i understood your question, but let me share something that may lead you to something useful. I understand you said there is no "backending code", but i hope this may contain some useful tip for your case.

When we use an image in Crystal Reports, it's type is base64Binary in the XSD.

In the dataset, it's type is byte[].

We save the image as a serialized string in the database. Something like that:

FileStream stream = new FileStream(filePath, FileMode.Open);
BinaryReader binreader = new BinaryReader(stream);
byte[] buffer = new byte[(int) stream.Length];
buffer = binreader.ReadBytes((int) stream.Length);
string serialized = Convert.ToBase64String(buffer)

We get it back as a byte array to put in the dataset:

byte[] buffer = Convert.FromBase64String(serialized)

In the Crystal Report design tool, we just drag the field to the document.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...