Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 831
  • Last Modified:

Passing long string to parameter field

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
SETP
Asked:
SETP
  • 8
  • 6
  • 4
  • +1
1 Solution
 
SETPAuthor Commented:
OK, just checked properly. It bombs when I send it more than 254 characters (i.e. 255 or more characters)
0
 
GJParkerCommented:
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
 
SETPAuthor Commented:
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
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
frodomanCommented:
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
 
GJParkerCommented:
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
 
SETPAuthor Commented:
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
 
mlmccCommented:
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
 
frodomanCommented:
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
 
SETPAuthor Commented:
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
 
GJParkerCommented:
Try :-

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

Gary
0
 
frodomanCommented:
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
 
SETPAuthor Commented:
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
 
SETPAuthor Commented:
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
 
GJParkerCommented:
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
 
SETPAuthor Commented:
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
 
GJParkerCommented:
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
 
frodomanCommented:
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
 
SETPAuthor Commented:
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
 
GJParkerCommented:
Glad I could help

I believe it is possible to split points between people.

Gary
0
 
mlmccCommented:
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 8
  • 6
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now