By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,967 Members | 1,172 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,967 IT Pros & Developers. It's quick & easy.

C# 2005 Beta, Crystal Repots 9, & Dynamically Setting Images at Runtime

P: n/a
I've had no success in trying to dynamically set images at runtime in a
Crystal Reports 9 report using C# 2005 Beta.

I've been doing research along these lines & all the posts I've read
say this can't be done.

I was wondering if I've missed anything or if Crystal Reports 10 has
added this feature?

I downloaded a sample VB6 project (cr9_vb_rdc_loadpic.exe) from where you could do the following:
Set Picture1.FormattedPicture = LoadPicture(picFile)
....where Picture1 is an ICROleObject and picFile is a string
representing the path to the picture file on disk. This works, but in
C# I can only reference PictureObject and BlobFieldObject not

Any help much appreciated.

Glen Richards

Nov 16 '05 #1
Share this Question
Share on Google+
5 Replies

P: n/a
I'm also trying to dynamically create a DataSet from the data in the
database & my picture files and use "ReportDocument class
SetDataSource()" but it always throws the exception: "InternalException
- Error in File C:\\Test\\Test.rpt:\nThe request could not be submitted
for background processing."

Any ideas or tips?

Nov 16 '05 #2

P: n/a
This is what you get for working with Beta software!

I never solved this problem in VS.Net 2005 Beta.

I did manage to solve my problem but only in VS.Net 2003 with CR.Net
that comes bundled with it.

The report had to be based on an xsd file (ADO.Net) & I had to create
the DataSet in code:

* In the xsd file, the type of the picture field was base64Binary.

* The code to dynamically display pictures looks like this:

// Grab a picture file from disk & load it into memory.
FileStream fs = new FileStream(@"C:\AnyPic.jpg", FileMode.Open);
BinaryReader br = new BinaryReader(fs);
byte[] pic = br.ReadBytes((int)fs.Length);

// Create your data structure in memory.
DataSet ds = new DataSet("Test");
DataTable dt = new DataTable("Test");
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("MyType", typeof(string));
dt.Columns.Add("MyValue", typeof(string));
dt.Columns.Add("MyPic", typeof(byte[]));

// Create a row - In practice, obviously, you would open up a
connection to a database to get your data.
DataRow dr1 = dt.NewRow();
dr1["Id"] = 1;
dr1["MyType"] = "Text";
dr1["MyValue"] = "Testing 1-2-3!";
dr1["MyPic"] = pic;

DataRow dr2 = dt.NewRow();
dr2["Id"] = 2;
dr2["MyType"] = "Text";
dr2["MyValue"] = "Testing 4-5-6!";
dr2["MyPic"] = pic;

// Set the data source for the report document (ReportDocument)
// Don't forget to refresh the report!

Hope that saves someone the couple of days frustration I had. Good

Nov 16 '05 #3

P: n/a
We are using exactly your solution in-house. One warning, though:
Crystal insists on scaling and stretching the image to fit the box you
put in the report template, so all images must have the same aspect
ratio or they will be distorted.

I called Business Objects and they told me that CR 10 does not allow
you to request that an image supplied in data be fit within a bounding
box while maintaining aspect ratio. It seems as though Crystal's image
support was written with the thought that people wanted to paste logos
and pictures into their reports as decorative touches, not in order to
include product images that might differ from one record to the next.

Anyway, are you saying that you can't get this to work in Visual Studio
2005 under the .NET 2.0 Framework? That would be a serious problem for
us. What exactly is it about your VS2003 solution that doesn't work in

Nov 16 '05 #4

P: n/a

I never got the above code to work in VS.Net 2005 Express Beta using
..Net 2.0 Framework. I'm assuming that it will work by the time VS.Net
2005 is released?

I guess my problem with not getting it working in VS.Net 2005 was:

* The VS.Net 2005 didn't come with CR.Net - we were using CR9 & Eval
CR10... I couldn't create reports based on xsd for either version (CR10
crashed for me when creating a report based on xsd).

* When trying to set the dynamic dataset for a report based on an odbc
connection, the dynamic data refused to be displayed. The report
always showed the data from the odbc connection no matter what I tried.

Nov 16 '05 #5

P: n/a
What version of CR9 / eval CR10 were you using?

According to the folks at Business Objects, you need to the
top-of-the-line, fancy "programmer's" designer in order to design
reports based on XSDs that can accept dynamic data from a .NET
application. Other versions of the stand-alone designer don't allow

I haven't tried it myself, though. However, I'm very interested because
we're talking about buying the stand-alone designer for some of our
staff. If it just plain "can't do" XSD and dynamic data, then that
will, of course, profoundly affect our decision.

The second behaviour you saw is something I would expect. We're very
careful never to tell the CR report designer in .NET where its data is
coming from. We don't even allow it to see a sample XML file for our
data; we show it the XSD and that's it. Our Crystal contact has told me
that we could point it to an XML file for design purposes and then
"switch it back" to the XSD before saving, but this seems too
error-prone to me.

My impression of CR is that it is primarily a pull-based reporting
engine. It wants to be pointed to its data source and do the data
extraction itself. Pressing it into service as a "push"-based reporting
engine (which is what we are doing) is really a bit of a hack on
Business Objects' part, as is the whole XML thing. CR doesn't read XML,
really. Neither is it really a reporting engine at which you can push
dynamic data. However, if you just twist it around like this... which
is what they did.

So, if you were to design a report based on an ODBC data source, I can
see the report template getting "stuck" on the idea that it's supposed
to pull its own data. After all, that's how the whole CR product was
designed. The whole "push" model thing is more a clever trick to make
CR do something it wasn't really designed to do, so we treat it with
kid gloves.

Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.