I have a crystal reports rpt file being called from C# code. Report works as expected from Designer within Studio 2010. Same report ignores Selection Criteria when called from C#, but ONLY when including a certain table's field in the criteria.
Current Criteria Example :
date({transaction.transaction_date}) in {?FromTo} and
{user_branch.branch_id} = 1
{?FromTo} is a date range parameter which works perfectly
When I remove the branch_id section, the {?FromTo} date parameter is checked correctly and the data returns as expected. BUT, as soon as I include the branch_id field, ALL the data is returned, which does not make sense at all.
Running this exact same report via the designer, works correctly... The problem occurs when running via C# SDK code.
Any help with this will be GREATLY appreciated
Already Tried
Recreate Entire Report from Scratch bit by bit, table by table. This works up to a point where I start adding more fields to the report itself, no one in particular, then the problem starts up again... So obviously, I start back tracing my steps until the entire report is empty again, but the problem persists, like the file is now "broken"
No similar issues in google... No where in my code is a line emptying the selection criteria during code... My other reports not accessing that table works fine.
Currently using version 13.0.1 of the CR Runtime. Tried to upgrade to 13.0.2, still didn't work
Ran the exact same SQL that the report generated directly against the database. That works as expected.
Try changing your criteria to:
(date({transaction.transaction_date}) in {?FromTo}) and
{user_branch.branch_id} = 1
Adding the date({transaction.transaction_date}) in {?FromTo} line inside a (). I'm not just sure.
After many head-aches this week, I finally found the problem... This looks like a bug in the SDK itself though, but to solve the problem, just make sure that the field giving the problem mentioned above is contained in the detail section of the report.
i.e. I added my branch_id field to the detail section of the report and suppressed it. It works by suppressing the section as well, just as long as the field is contained there.
I tested this on all my other reports with the same problem and it worked.
Related
this question is about adding a new field called "Position" of type integer into an existing table via the Entity Framework designer. What I expect to happen (correct me if I am wrong) is add the field, select to update the database via the model and get the new field created in my database. Instead of this, I get an "Error 3004 Problem in mapping fragments at line xxx". My environment is using Visual Studio 2015 with EF5, and the database is hosted on Oracle MySQL. The project I am working on is a website which was given to me to maintain and upgrade further.
Here are my steps:
1. Discover the table in the model browser, click Show in Diagram.
2. Inside the model I right-click on the table -> Add New -> New Scalar Property and type the new field "Position" inside the table.
3. Click save icon to save the model
4. Then I get an Error 3004:
5. I realise that in the mapping details my new field isn't showing and I can't type in there to add it manually.
6. I can see the new field has been added to the syncitem class in fact I want this to be an integer so I go ahead and change it by hand.
Tried to click save again and re-compile but I still get the same error. I need to say at this point that I have spent an entire day searching around on the web about various error codes I got other than just 3004 but here is where I stopped and turned to SO for guidance. I know there are other threads here about Error 3004 and I did read quite a few them. One of the pieces of advice I found was to change the DDL generation template to one that supports MySQL since Visual Studio will default to SQL (this is done by clicking on the white space inside the designer and then clicking the Properties tab):
I tried that as well but nothing changed, the error persists... I also tried deleting the entire table in the designer and updating from the database, the table re-appeared but with a torrent of "Error 11007" lines, plus the table's associations are not wired correctly. Another thing I did was to open the .edmx file in Notepad++ and see if I can add my new field in there, but it just felt wrong doing it like that so I quit.
Am I approaching this in the wrong way? All I want to do is add a new field! I have come to a stop, my experience with EF is not great, I felt lots of frustration with this database's particular setup, quite frankly I dare say that I think it is somewhat broken. It's like dealing with a brand new religion whenever I have to touch it!
In the long run I want to upgrade to EF6 and get rid of the designer but that's another story.
Any advice on my problem will be greatly appreciated.
Thanks.
Eventually I had to tamper with the XML file of the model (the .edmx file) to manually add in my new field and set it to integer, as there was nothing I could do to satisfy Visual Studio. The web project I am working on looks rather complicated with loads of sub-projects in it like "DataAccess", "EntityModel", "ManagerLayer", my web folders and a host of other directories. I think my EF needs a complete re-do, my guess is that it started with a very old EF version and is shuffling its feet right now in terms of maintainance.
I have a c# project where i created a dataset, then when through the steps of creating 3 reports via the Report Wizard. The rdlc files are now in my project and i have a reportviewer control in my Winforms project. The question is, after going through the process of setting up the dataset and reports, how do i get any of them to display in the reportviewer? When i try to set the ReportEmbeddedResource to be one of the rdlc files, i get a message in the viewer saying the source of the data has not been set. I did that when i created the data set and the report.
Any ideas?
Here is a detailed tutorial on how to use Local Reports : http://msdn.microsoft.com/en-us/library/ms252075%28v=vs.90%29
I had to do this last year, Local Reports are kind of a headache. The problem is .rdlc files do not fill their data sets (they ignore all the <Query tags. So, what I had to do is write a custom .ascx that would parse the <Query> tags in the .rdlc, fill the DataSets, and pass the new file to the ReportViewer control.
Basic steps:
1. Build a set of input fields based on the QueryParameters inside any <Query> tags. This usually involved cascading comboboxes since parameters can be dependent.
2. When the user submits the form, fill the DataSet associated with each <Query>.
If you look at the way you input parameters in VS 2008 when you test an RDL, the control you will make does exactly that.
All of this had to be done because of a client request to not have to authenticate when running the report...ugh. The fun thing is, I never found a complete schema for RLD/RDLC XML so I had to look at a lot of report files to figure out all the variations.
EDIT: I missed the part where you said WINFORMS. My scenario was for Webforms, though it might still apply I've never used the ReportViewer control in Winforms.
AoA, Hello
i am writing an application for financial solution. in short i ve to get out print of report that is generated. Crystal report is what i want to use....
my problem is that i just want to preview report and allow to insert any change that user want to make. Or easily we can say want to allow edit entries.
is there any method to preview?.... Note that i am newbie ..... so apology if i am unable to deliver correct question. Hope you understand and will help me.
take care.
You don't say what type of project you are working on (ASP? Winforms?)... but I suspect the answer may be similar in all cases.
While a preview control is available in Crystal Reports (at least version XI, for WinForms based solutions), I am 95% certain that the preview is non-editable. I believe that if you wanted to change fields within the report you would need to "re-run" the report processing before you could get an updated preview.
I have a Crystal Report that was designed against a dev database. When I load it into the live system I need it to run a different but equivalent database. Normally I just run reports through some code in C# that sets the connection info, parameters and calls VerifyDatabase on the report and subreports and it all works well.
In one particular report this doesn't work though and doesn't seem to verify anything and the report crashes with an error 'The field name is not known' in one of the sub reports. With this report if I manually verify it in the Crystal Reports application against the live database then it all works fine.
So the question is, is there anything different that Verify Database function in the Crystal application does that I should do in code other than set connection info, parameters and call VerifyDatabase method?
Edit: Some more info on what I tried
Get a backup of the live database and put it on our dev environment.
Manually verify the report against this database (which is exactly the same structure as live)
Load the report into the live system and run it.
Error still occurs.
The 'field name is not known' error usually means that you have placed a field on the report or used it in a formula (etc), but the field no longer exists in the database. As I understand it, calling VerifyDatabase can update the field list for the views/tables in the report, and can remove fields from the report if they no longer exist, but it cannot fix formulas or subreport links which depend on a missing field.
It seems to me a better practice to make sure that the database is in sync (verified) before deploying the report so you don't need to call VerifyDatabase every time.
All that said, I don't see why it would work after manually verifying, but not after calling VerifyDatabase. Sometimes Crystal is weird that way. You might try recreating the subreport (if it is simple), or removing it and rebinding it to try to trick the error into going away.
It sounds like a confusion between two versions of Crystal and their capabilities. The version that comes with dotNET 2008 is Crystal Reports Basic for VS2008, masquerading as Crystal 10.5 (which doesn't exist as a standalone product). But if you're referring to standalone reports developed by themselves outside of the Visual Studio IDE, then this will be a different version of Crystal with some differences in capability. I'd say this report was created in a different version of Crystal to the others, and that the Verify within the code is coming across some feature that 10.5 can't recognise.
If you have a standalone version of Crystal (which will need to be either Crystal Reports 2008, or a Developer edition of an earlier version), use this to make sure you're using the same Crystal version in the app as in in report development.
Could you verify this:
While the debugger is running, if the schema in a typed dataset is changed and you run Verify Database the messagebox always displays "Database up to date" even though there is a difference in the two schemas.
This took me a while to figure out because the Verify Database action was not disabled when the debugger was active.
Afternoon Developers,
I have a problem that's beginning to get on my wick. I have looked through google and Crystal Reports help and am still stuck for a solution.
We have created an XSD complete with full information about data-types and the like.
A report has been created that is linked to this XSD (using a c# class generated using Microsoft's xsd.exe SDK) and uses the field information to fill the report.
From c# we are instantiating this report and populating it with an XML file that conforms to this XSD and has been validated against it.
Now the problem is that although everything validates without errors (Crystal formulas etc) and compiles fine, when we run the application and attempt to populate the Crystal Report the Report seems to loose all knowledge of the data-typing.
Formulas such as
if ({LetProperty.lp_buildings_selected} = true) then
"Standard Cover With Accidental Damage Cover"
else
"Standard Cover";
come back with "A string is required here." error. This formula should run fine as the field referenced is a Boolean Data-Type, Crystal Reports knows this in design time.
To get it to work we have been needed to cast the field ToText and compare it to 'true'.
This is a simple work around but we will be creating many reports and don't want to twist code that should work into 'Fudged' messy code that will work.
Can anybody tell me if I am missing something glaringly obvious or if there is something that we need to set as this is confusing us immensely!
Many Thanks all.
Right,
I just wanted to let anyone know how we solved this if anyone ever gets stuck in the same situation.
What we needed to do was before populating the created dataset from the Xml file (to pass to the Report) we read the Xsd into the Dataset so that it was then strong typed and contained all the Data-typing information also.
I don't know why crystal doesn't keep all the Data-Type information that was assigned to it when we created it and linked it to the Xsd but this is how we got around that.
Is LetProperty.lp_buildings_selected set to anything besides "true" or "false" in the XML document (perhaps empty string)? If so this may be the reason that Crystal Reports is trying to use it as a string.
I believe the generated XSD is probably set up by the prevent that, but thought I'd throw it out there anyway.
Is the problem just that you need to include the schema in each XML file? Doing this will have the full type information sent to Crystal as you tell it the XML file is the DataSource. I think I had a problem like you mentioned when I did not include the XSD in the header of the XML file.