cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with crystal report (asp.net 2003)

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

former_member183750
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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.

former_member208657
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi David,

Thanks for sending me the code..

I tried your code and the issue remains the same.. Its still not working...

My exact issue is Suppose there is a column in my report as below:

Col A

1

2

0

2

Its displaying as:

1

2

2

where 0 is omitted.

Thanks to help.

former_member208657
Active Contributor
0 Kudos

A few suggestions ...

1. Recreate your report

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.

2. Null Data

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.

3. Validate your results

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?

Former Member
0 Kudos

Hi David,

Below formula is used in this report. Here i think if value is '0', then its preventing it from being displayed.

iif ({@RptMonth} = {@CurrentMonth} AND {@RptYear}=2008.00,{@Amt}/1000,0)

Kindly let me know what shall be done in this case.

Thanks.

Answers (0)