cancel
Showing results for 
Search instead for 
Did you mean: 

Left(str, #) w/CrystalReportViewer when 2nd arg is a variable?

Former Member
0 Kudos

Using the VS2005 CrystalReportViewer control, this field formula should return "Linkoln, NE". Instead I get blanks.

Using Crystal Syntax in my report.

If I comment out the last three, lines, I get junk symbols.

(Note, I always get the expected result in Crystal Report Developer, it's only in the web control that the field doesn't display.)

Formula:

StringVar bankTown ;

NumberVar positionOfLastChar ;

bankTown := "Linkoln, NE 12345" ;

positionOfLastChar := InStr (1, bankTown, ",") + 3 ;

"the last char is at" + CStr(positionOfLastChar) ;

left(bankTown, positionOfLastChar) ;

left(bankTown, 11) ;

positionOfLastChar := 11 ;

left(bankTown, positionOfLastChar) ;

Any workarounds? (I'm going to try using basic syntax first)

Accepted Solutions (1)

Accepted Solutions (1)

former_member208657
Active Contributor
0 Kudos

Try exporting the report to Crystal Reports format. Then, inspect the new report with the Crystal Reports designer to see your results. You'll need to do this to determine if this is a rendering issue in the CrystalReportViewer for the web or something wrong with your formula.

Former Member
0 Kudos

Good idea. Okay, here's formula that exhibits the problem. This is designed to strip anying following ST in an address that looks like "City, ST 12345"


StringVar BankName ;
NumberVar Pos ;
BankName := {GBH.BANK_NAME_ADD#3};
Pos := InStr (BankName, ",") + 3 ;
Left (BankName, Pos);

That is in a formula field which is displayed on the report. When I run the report in CRXI, all looks fine. When I load the .rpt file in ASP.Net, VS2005, using a CrystalReportViewer object, nothing dispalys wher the formula field should be.

I save the report from ASP.net by exporting to .RPT format.

I load the .RPT format in CR XI. It shows with saved data, and where the formula field is, it is blank. I hit "Refresh", use current parameters, and the field appears on the report where it is supposed to be.

So I conclude that the formula evaluator in the ASP.net control is what is failing.

I also found that a more direct expression has also fails to show in ASP.net viewer:


StringVar BankName ;
BankName := {GBH.BANK_NAME_ADD#3};
Left(BankName, InStr (BankName, ",") + 3 )

The obvious expression:

Left ({GBH.BANK_NAME_ADD#3}, (InStr ({GBH.BANK_NAME_ADD#3}, ",") + 3))

Works fine in CRXI, but gets gobbledygook (cyrillic, boxes, arabic) junk in ASP.net

So I think anyone should be able to replicate this with something like:

StringVar pie;

NumberVar pos ;

pie := "I like Pie";

pos = 3+3 ;

left(pie, pos)

Which should come back with "I like" - does that formula field work for anyone when displayed in ASP.net?

former_member208657
Active Contributor
0 Kudos

So I conclude that the formula evaluator in the ASP.net control is what is failing.

I'm not convinced the problem is with the reporting engine in ASP.NET. The report is actually run through the same engine from the .NET app as it would be through the designer. I've never seen a formula be evaluated differently in the designer vs. a .NET app.

I think you should drop your {GBH.BANK_NAME_ADD#3} field on your report beside your formula. Run the report in the designer and observe the value of {GBH.BANK_NAME_ADD#3}. Next run it in your .NET app.

If you see different results you should ask yourself if you are changing databases at runtime. Distinct data will be evaluated differently by a formula and produce unique results.

Answers (2)

Answers (2)

Former Member
0 Kudos

About ASP.Net viewer rendering junk when using "Left":

Wanted to bump this and see if anyone had any thoughts. I've got new data too, I'm guessing "Reinstall merge modules" is going to be the path to take.

I create a report with no connection to any data. I have a single field function, which I show in a text box. The field function is

stringvar s := "ABCD";

numbervar n := 2;

Left(s,n)

In Crystal Reports Developer, the textbox shows "AB", and when I display the RPT file using the ASP.NET control that comes with VS2005, one one web server I get binary junk - boxes, arabic, cyrillic, symbols. But when I put the same application, loading the same report definition on antoher server, it shows "AB".

So is there any other possible interpretation except that the rendering logic is breaking on the first web server, and the way to fix it is probably to reinstall the Crystal Merge Modules? What's odd is, except for this one thing, everything seems fine on the first web server - we have real reports that use data from ODBC, and except for a field that we trim down using Left, we haven't found any other problems.

So I guess it's possible something else in .NET is munged and is getting triggered when Crystal calls Left()?

Thanks

Former Member
0 Kudos

Well, yeah, I did a bunch of tests like that, and the field is always what I expect it to be if I just drop it on the report. And as per my original report, I'm seeing this same thing with string literals.

The web server isn't the same machine as I'm previewing reports on. Maybe we have to look at what merge modules are on the web server? Should I check to see what versions of libraries are availalbe in the GAC? Do you know which ones?