?
Solved

Passing long string to parameter field

Posted on 2005-04-04
20
Medium Priority
?
811 Views
Last Modified: 2008-01-09
Hi

I have a Crystal Report (the one bundled with Visual Studio .NET 2003), that has a couple of parameter fields (no database stuff) and is working perfectly. I'm populating the parameter fields in runtime from VB.NET 2003. But I just realized that for one of the text parameter fields, if I pass it more than a certain amount of characters (I think 256 characters) it throws the following exception:

An unhandled exception of type 'System.ArgumentException' occurred in crystaldecisions.crystalreports.engine.dll

Additional information: Value does not fall within the expected range.

Any idea how to overcome this problem? I have to send the parameter about a page worth of text.

Thanks
0
Comment
Question by:SETP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
  • 4
  • +1
20 Comments
 

Author Comment

by:SETP
ID: 13698509
OK, just checked properly. It bombs when I send it more than 254 characters (i.e. 255 or more characters)
0
 
LVL 19

Expert Comment

by:GJParker
ID: 13698689
Text objects prior to version 9 (.NET 2003 is based on V9) had a limit of 255 characters. There may be a hotfix avaialable to fix this http://support.businessobjects.com/communityCS/FilesAndUpdates/crnet11win_en.zip.asp

As a matter of interest what are you using this paramater for do you really need to filter on a full page of text ?

Gary
0
 

Author Comment

by:SETP
ID: 13698773
Thanks for the reply. I installed the latest hotfix but still has that problem. What I'm doing is basically as follows:

The user types a letter in a standard windows text box and clicks print. That launches a form with a CrystalReportViewer on it, which loads the report with a company logo and footer, some other data (client address, reference number, etc) and then in the main section the actual letter. This then gets printed and posted (or e-mailed or faxed)
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 42

Expert Comment

by:frodoman
ID: 13698855
As far as I know there is no fix for this issue prior to version 9.  As a suggestion you might want to take what the user has typed and write it out to a database field then launch your CRViewer to load the report that pulls the data you've just written from a db table.  This will get you around the length of the parameter problem.

(of course I'd consider using MS Word instead of Crystal for this if you have that option).
0
 
LVL 19

Expert Comment

by:GJParker
ID: 13698875
I personally don't use .NET so can't try this out, but I would suspect CR is getting upset with the amount of data ina  paramater field. Instead of using a paramater field try inserting a formula field or Text object and set tthe text value of this at run time.

Gary



0
 

Author Comment

by:SETP
ID: 13698906
Any ideas how can I set the text value of a Text or Formula object at run time? I only know how to set the value of a Parameter field at runtime. Can this even be done?
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 13700081
I agree.  Crystal changed it so text fields longer than 254 characters could be used in formulas but I suspect there may still be a limit on parameters.

Formulas can be set in a manner similar to parameters.

mlmcc
0
 
LVL 42

Expert Comment

by:frodoman
ID: 13700854
Here's the code to set a formula at run time:

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

'Above the statement, "#Region ... ", add the following lines of code.

Dim crReport as New CrystalReport1()

'After the call to InitializeComponent() in the form's constructor, type the following code
'to set the formula field

crReport.DataDefinition.FormulaFields.Item("FormulaName").Text = "({Customer.Last Year's Sales} * 5) / 3"

'Set the viewer to the report object to be previewed.
CrystalReportViewer1.ReportSource = crReport

(from: http://support.businessobjects.com/library/kbase/articles/c2010354.asp )
0
 

Author Comment

by:SETP
ID: 13704678
But can I add just text instead of a formula? Because it gives me an error:

========================================
Error in formula <Message>
'This is a test 1234567890'
The remaining text does not appear to be part of the formula
========================================

This is the code I used:

Dim crFormulaFieldDefinitions As FormulaFieldDefinitions
Dim crFormulaFieldDefinition As FormulaFieldDefinition

crFormulaFieldDefinitions = CrystalReport1.DataDefinition.FormulaFields
crFormulaFieldDefinition = crFormulaFieldDefinitions.Item("Message")
crFormulaFieldDefinition.Text = "This is a test 1234567890"
0
 
LVL 19

Expert Comment

by:GJParker
ID: 13706102
Try :-

crFormulaFieldDefinition.Text = "'This is a test 1234567890'"

Gary
0
 
LVL 42

Expert Comment

by:frodoman
ID: 13706446
That's it.  You need to include the single quotes because what's inside your double-quotes should be the same text you'd enter from the crystal designer.
0
 

Author Comment

by:SETP
ID: 13706884
Thanks for all your help guys. Well, that solved the 254 character max length problem, but now it brings another problem. You can't have carriage returns in the string that you pass it. So the user would have to type a letter as one long paragraphs with no blank lines! Aaaagh!!! Just when I though I had it! :( Oh well, I guess I can write the data to a database and then pass it to the report. But before I do, is it possible to change the text of a plain Text Object in the report? Can I get a handle to it?

Thanks
0
 

Author Comment

by:SETP
ID: 13707118
I saw that the Formula field in Crystal Reports allows you to insert, well, formulas. And there is one String formula which looks like this:

     Replace (inputString, findString, replaceString)

I've never used formulas before, so I'm a bit syuck here, but could I not maybe use this formula to replace all events of a string, for example, '===' and replace it with carriage returns? Then from my VB app, I will replace all carriage returns with "===".

Does anyone think that might work? If so, how can I use these formulas?

Thanks a million
0
 
LVL 19

Expert Comment

by:GJParker
ID: 13707215
That sounds lie a good idea, you would use the replace() function like this :-

Replace ('This is how to===place carriage returns===in a text object','===' ,chr(13))

this should display

This is how to
place carriage returns
in a text object

Gary
0
 

Author Comment

by:SETP
ID: 13707372
OK, is the example you gave me above what must be inserted into the formula field in the Crystal Report? Or is it something I must do in my VB code? Because I must replace the hard-coded sample sentence in the example above with the the text that I'm sending the formula field. How is this done? Sorry - I've got almost zero Crystal Report experience (and I'm sure it shows)

Thanks
0
 
LVL 19

Accepted Solution

by:
GJParker earned 2000 total points
ID: 13707522
create the formula field on the crystal report and leave it blank, and then add this as the code in your .net Code

crFormulaFieldDefinition.Text = "Replace ('This is how to===place carriage returns===in a text object','===' ,chr(13))"

Gary
0
 
LVL 42

Expert Comment

by:frodoman
ID: 13707855
Another option is to replace the === with <BR> and make sure you've formatted the formula field to use HTML text interpretation.  The advantage to this approach is that it allows you to also use other HTML formatting tags if you want to use bold text, italics, etc.  If you have no interest in ever doing that then stick with chr(13).
0
 

Author Comment

by:SETP
ID: 13709431
Thanks guys. You really helped me a lot. It was difficult deciding who to give the points to, but unfortunately I could only choose one of you. But both really helped me a lot.

Regards
0
 
LVL 19

Expert Comment

by:GJParker
ID: 13714787
Glad I could help

I believe it is possible to split points between people.

Gary
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 13723534
Yes, splitting is possible.

Before you accept the answer, there is a link below the last comment and before the new comment block to SPLIT POINTS.  When you click that you can allocate the points to any or even all the comments that helped.

If you wish to do that submit a request in the Community Support forum to reopen this question.

mlmcc
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question