on 08-04-2008 8:00 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.