473,383 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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

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
http://www.businessobjects.com/ 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
ICROleObject.

Any help much appreciated.

Cheers,
Glen Richards

Nov 16 '05 #1
5 7838
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
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);
br.Close();

// Create your data structure in memory.
DataSet ds = new DataSet("Test");
DataTable dt = new DataTable("Test");
ds.Tables.Add(dt);
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;
dt.Rows.Add(dr1);

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

// Set the data source for the report document (ReportDocument)
crystalReport11.SetDataSource(ds);
// Don't forget to refresh the report!
crystalReportViewer1.RefreshReport();

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

Nov 16 '05 #3
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
VS2005?

Nov 16 '05 #4
Hi,

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.
Cheers,

Nov 16 '05 #5
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
this.

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Stephan | last post by:
Hi, I'm using Visual Studio 2003 (C#) with the integrated Crystal Report software and have the following question: How can I assign a value (string) to an unbound (string) field in Crystal...
0
by: hem | last post by:
in my web application, i want to show dynamic images at runtime with crystal report.net. the image is residing in my local computer, i am having problem at runtime i.e. how i give the image path...
15
by: binnyva | last post by:
Hello Everyone, I have just compleated a JavaScript tutorial and publishing the draft(or the beta version, as I like to call it) for review. This is not open to public yet. The Tutorial is...
1
by: Peted | last post by:
Hi, sorry if this isnt the correct newsgroups for this questions but im using vc++ 2005 express edition beta2 for learning to program vc++ ..net, as in winforms applications and i was wondering...
0
by: Robert Warnestam | last post by:
Hi, Is there somebody that have managed to deploy a web application using; Visual Studio 2005 Beta 1 Bundled version of Crystal Reports (or with Crystal Reports XI) If that's case? how...
13
by: David L Wright II | last post by:
Does anyone know when building a msi file under VB.Net 2003, it would try to install something from the VS 2005 Beta 1? I have both products installed. Thanks,
5
by: Jay | last post by:
I am getting mixed messages from the asp.net website hosting providers - some say they do not support Crystal Reports due to a $25,000 per cpu licensing fee, others say all I need to do is install...
1
by: ngpost1 | last post by:
I have a Crystal Reports.Net report being generated from my C# application. I would like to change the background color of the details section (not the text mind you) of the report on certain...
1
by: BRAHM | last post by:
Hi, I am creating reports using the crystal reports available in VS 2005. I am not figuring out how to load dynamically images in a picture box (at runtime) inside of my reports. how could...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.