on 10-14-2008 8:03 AM
Hi,
I have some issues with crystal report in my web application (asp.net 2003) ....
In my web application, i have n no. of reports..say 10.. all work fine except 2 of them.
The issue with these 2 reports is that, though i can view them at run time, it displays incomplete data.
That is, when i load the report from my local drive, it shows incomplete data...using below code..
[CODE]crReportDocument.Load(ables.strDocPathFolder + "\" + "ABC.rpt")[/CODE]
But when i add this report to my project and run application, it works fine..using below code:
[CODE]Me.CrystalReportViewer1.ReportSource = Server.MapPath("ABC.rpt")[/CODE]
I want to load this report, and not to add it in my project..as this report can be changed anytime from outside.
Thanks to help.
Hi, Mohamed;
Are you using any other code regarding the reports? ie, are you setting any selection formulas? How are you logging on to the database? Which version of Crystal Reports are you using?
Best Regards,
Jonathan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jonathan,
The code am using is below
Private Sub GetReportData()
Try
Dim crReportDocument As New ReportDocument
Dim ConnInfo As New ConnectionInfo
With ConnInfo
.ServerName = gbVariables.StrReportServer
.DatabaseName = gbVariables.strReportDBName
.UserID = gbVariables.strUsrName
.Password = gbVariables.strUsrPwd
End With
crReportDocument.Load(gbVariables.strDocPathFolder + "\" + "ABC.rpt")
Me.CrystalReportViewer1.ParameterFieldInfo.Clear()
Dim ParamFields As ParameterFields = Me.CrystalReportViewer1.ParameterFieldInfo
'Set Month Paramter
Dim Per As New ParameterField
Per.ParameterFieldName = "IniDate"
Dim Month_Value As New ParameterRangeValue
Month_Value.StartValue = Session("fromdate")
Month_Value.EndValue = Session("endDate")
Per.CurrentValues.Add(Month_Value)
ParamFields.Add(Per)
Me.CrystalReportViewer1.ParameterFieldInfo = ParamFields
Me.CrystalReportViewer1.ReportSource = crReportDocument
crReportDocument.SetDatabaseLogon(gbVariables.strUsrName, gbVariables.strUsrPwd, gbVariables.StrReportServer, gbVariables.strReportDBName)
Me.CrystalReportViewer1.RefreshReport()
CrystalReportViewer1.Visible = True
Catch ex As Exception
lblError.Text = ex.Message.ToString
End Try
End Sub
In code am not setting any selection formula...
am logging into database using crReportDocument.SetDatabaseLogon method as above in code.
Am using CR version 8.5 + asp.net 2003
Thanks to let me know where am going wrong.
Edited by: Mohamed Yasin Ismail on Oct 16, 2008 8:00 AM
Not sure why you are using ConnectionInfo, before loading the report? I suspect the ConnectionInfo is not doing much in this case. Also, after you use the ConnectionInfo and pass in all the parameters, you use SetDatabaseLogon? I'd suggest you use either ConnectionInfo or SetDatabaseLogon - after you load the report. That looks a bit convoluted to me(?). For sample apps look here:
https://smpdl.sap-ag.de/~sapidp/012002523100006252822008E/net_win_smpl.exe
and here:
https://boc.sdn.sap.com/dotnet/samples
You may also want to consider checking out this White Paper:
http://www.businessobjects.com/global/pdf/dev_zone/VS2005_Walkthroughs.pdf
If none of the above helps, provide the following information:
1) define "incomplete" data
2) What version of CR are you using?
3) make absolutely sure that you are using exactly the same report (I'd suggest setting the background of one filed to, say green and test with this obviously modified report
4) What database are you using?
5) What is the database connection type?
Ludek
Hi,
Thanks for reply.I used only SetDatabaseLogon and still with same issue.
Try
Dim crReportDocument As New ReportDocument
crReportDocument.Load(gbVariables.strDocPathFolder + "\" + "ABC.rpt")
Me.CrystalReportViewer1.ParameterFieldInfo.Clear()
Dim ParamFields As ParameterFields = Me.CrystalReportViewer1.ParameterFieldInfo
'Set Month Paramter
Dim GetMonthValues As Int16
GetMonthValues = Session("Month")
Dim Per As New ParameterField
Per.ParameterFieldName = "SELECTMONTH"
Dim Month_Value As New ParameterDiscreteValue
Month_Value.Value = GetMonthValues
Per.CurrentValues.Add(Month_Value)
ParamFields.Add(Per)
Me.CrystalReportViewer1.ParameterFieldInfo = ParamFields
Me.CrystalReportViewer1.ReportSource = crReportDocument
crReportDocument.SetDatabaseLogon(gbVariables.strUsrName, gbVariables.strUsrPwd, gbVariables.StrReportServer, gbVariables.strReportDBName)
Me.CrystalReportViewer1.RefreshReport()
CrystalReportViewer1.Visible = True
Catch ex As Exception
lblError.Text = ex.Message.ToString
End Try
Below are the answers for the questions you asked...
1) define "incomplete" data
"It means suppose there are 5 rows and if any one row has a value '0' its not appearing in report"
2) What version of CR are you using?
"Am using CR 8.5"
3) make absolutely sure that you are using exactly the same report (I'd suggest setting the background of one filed to, say green and test with this obviously modified report )..
"Yes i have tested this several times."
4) What database are you using?
"Am using SqlServer 2005"
5) What is the database connection type?
"OleDb"
Thanks to help.
There are a few issues with the code in this case. First you are mixing the Viewer SDK and ReportDocument SDK. You should really stick with one. In your case you are loading a Crystal Report from disk into a ReportDocument object. This is the most powerful object in the CR .NET SDK. Bringing in the Viewer SDK will only hinder your efforts.
I've edited some of your code and commented out some parts that are not needed.
Try
Dim crReportDocument As New ReportDocument
crReportDocument.Load(gbVariables.strDocPathFolder + "\" + "ABC.rpt")
crReportDocument.Refresh()
'Me.CrystalReportViewer1.ParameterFieldInfo.Clear()
' This is wrong. There is no need to access the ParameterFieldInfo property of the
' viewer. You are using a ReportDocument and should do all your work there.
'Dim ParamFields As ParameterFields = Me.CrystalReportViewer1.ParameterFieldInfo
' Database Logon Code
crReportDocument.SetDatabaseLogon(gbVariables.strUsrName, gbVariables.strUsrPwd, gbVariables.StrReportServer, gbVariables.strReportDBName)
' Parameter Value Code
'Set Month Paramter
Dim GetMonthValues As Int16
GetMonthValues = Session("Month")
'Dim Per As New ParameterField
'Per.ParameterFieldName = "SELECTMONTH"
Dim Month_Value As New ParameterDiscreteValue
Month_Value.Value = GetMonthValues
'Per.CurrentValues.Add(Month_Value)
'ParamFields.Add(Per)
crReportDocument.SetParameterValue("SELECTMONTH", Month_Value)
Me.CrystalReportViewer1.ReportSource = crReportDocument
' if you want new data you should refresh the ReportDocument
'Me.CrystalReportViewer1.RefreshReport()
CrystalReportViewer1.Visible = True
Catch ex As Exception
lblError.Text = ex.Message.ToString
End Try
A few suggestions ...
You mentioned this report was created in Crystal Reports 8.5. It is possible there is a problem moving from 8.5 to Crystal Reports for Visual Studio .NET 2003. Recreate a simple version of the same report. If you find this works then ditch your 8.5 report and move on with the new one.
Is it possible your 0 data is actually stored as NULL in your database? If so you'll want to enable the Convert Database NULL values to default in your Report > Options menu.
How did you validate your results? Did you run the same query directly against the database? What is the actual value stored in the database? Can you run another report that returns this data correctly? Do you have any conditional formatting in this report that would prevent this data from being displayed?
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.