cancel
Showing results for 
Search instead for 
Did you mean: 

No records shown in report ?

Former Member
0 Kudos

I have created a crystal report using ado.net dataset ("OleDB to SQL server database") and load it to a crystal report viewer in testreport2.aspx. No errors when run but no records where shown.

There is no problem with the data table return from GeneralProduct class as the DropDownList1 contains 30 item and textbox1 displays a total of 30 records from data table return.

=================================================

Imports CrystalDecisions.CrystalReports.Engine

Partial Class testreport2

Inherits System.Web.UI.Page

Private oRpt As ReportDocument

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Not IsPostBack Then

CrystalReportViewer1.EnableDatabaseLogonPrompt = False

oRpt = New ReportDocument

oRpt.Load(Server.MapPath("CrystalReport2.rpt"))

Dim _GeneralProduct As New GeneralProduct

_GeneralProduct.GetGeneralProductDataTable()

TextBox1.Text = "Record Count [" & CStr(_GeneralProduct.RecordsCount) & "]"

oRpt.SetDataSource(_GeneralProduct.oDataTable)

CrystalReportViewer1.ReportSource = oRpt

CrystalReportViewer1.DataBind()

CrystalReportViewer1.RefreshReport()

dd.DataTextField = "ProductID"

dd.DataValueField = "ProductID"

dd.DataSource = _GeneralProduct.oDataTable

dd.DataBind()

_GeneralProduct = Nothing

End If

If IsPostBack Then

oRpt = Session.Item("oReport")

CrystalReportViewer1.ReportSource = oRpt

End If

End Sub

Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload

Session.Add("oReport", oRpt)

End Sub

End Class

=================================================

Someone please assist....

Edited by: Kong Meng Chang on Aug 4, 2008 3:13 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi there,

Using Visual Studio 2008, I have created a crystal report with ado.net dataset ("OleDB to SQL server database") and load it to a crystal report viewer in testreport2.aspx. No errors occurs when run but no records where shown.

There is no problem with the data table return from GeneralProduct class as the DropDownList1 contains 30 item and textbox1 displays a total of 30 records from data table return.


Imports CrystalDecisions.CrystalReports.Engine

Partial Class testreport2
    Inherits System.Web.UI.Page
    Private oRpt As ReportDocument

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            CrystalReportViewer1.EnableDatabaseLogonPrompt = False
            oRpt = New ReportDocument
            oRpt.Load(Server.MapPath("CrystalReport2.rpt"))
            Dim _GeneralProduct As New GeneralProduct
            _GeneralProduct.GetGeneralProductDataTable()
            TextBox1.Text = "Record Count [" & CStr(_GeneralProduct.RecordsCount) & "]"
            oRpt.SetDataSource(_GeneralProduct.oDataTable)
            CrystalReportViewer1.ReportSource = oRpt
            CrystalReportViewer1.DataBind()
            CrystalReportViewer1.RefreshReport()
            DropDownList1.DataTextField = "ProductID"
            DropDownList1.DataValueField = "ProductID"
            DropDownList1.DataSource = _GeneralProduct.oDataTable
            DropDownList1.DataBind()
            _GeneralProduct = Nothing
        End If
        If IsPostBack Then
            oRpt = Session.Item("oReport")
            CrystalReportViewer1.ReportSource = oRpt
        End If

    End Sub

    Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
        Session.Add("oReport", oRpt)
    End Sub

End Class

Someone please assist....

Edited by: Kong Meng Chang on Aug 4, 2008 3:13 PM

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Ludek,

You have given me a workaround with the dataset idea. I modify the Crystal Report using an XML file but have error. I try to use a ADO.NET dataset instead but it didn't work either.

Finally i recreated a new Crystal Report with the ADO.NET dataset instead of modfiying and it works. All records are correctly shown.

Thank you very much for leading me to the solution....

former_member183750
Active Contributor
0 Kudos

Good stuff. Happy it's working for you

Ludek

Former Member
0 Kudos

I have generated the xml file. Set database location to the xml file path. Replace all fields with new Dataset Fields. One of the fields is a picture field, when added displays the product picture in design time. When click on "Main Report Preview" and this error message pops up "This field name is not known" without previewing the report...

former_member183750
Active Contributor
0 Kudos

Take the error at face value. The field is not known to the report or in other words, the report has no idea what to do with that field. Ensure that the field is acceptable to the report...

Ludek

Former Member
0 Kudos

Hi Ludek,

I am using Visual Studio 2008 Professional Edition come with Crystal Report. How do I check CR the version number ?

Thanks for replying...

former_member183750
Active Contributor
0 Kudos

You should still be able to find that database menu in that versions. Then select the DataSource to be ADO .NET (XML) and see if the report previews.

Ludek

former_member183750
Active Contributor
0 Kudos

As you don't specify version of Crystal Reports used, I will assume you are using a non bundled version of CR (please specify version of CR when posting to the forum).

When using datasets and you do not see the data as expected, 99% of the time is a data issue (usually a format issue).

Best way to troubleshoot ADO .NET dataset issues, is to save the dataset to an XML as:

myDataset.WriteXml(xmlPath, XmlWriteMode.WriteSchema)

I recommend doing this just before you set the dataset to the report. Then, open the repot in the CR designer. Go to the Database menu and select Set DataSource location. Point the report at the above exported XML using the ADO .NET driver (ADO .NET (XML)). See if the report runs in the designer. If you get Field Mapping dialog, this tells you that the report an not match the dataset to the fields it expects. You then have to modify your dataset to match the report.

Ludek