locked
Crystal Report Display Only First row RRS feed

  • Question

  • User1119347574 posted

    Hi,

    When my procedure returns more than one row...but on field section of my crystal rport it displaying only the first row.....why it is not showing all the rows

    weather we need to change any setting for this........urgent help me............

    Friday, September 13, 2013 11:09 PM

All replies

  • User2103319870 posted

    Hi,

    Please try the solution suggested in below link

    http://forums.asp.net/t/1128061.aspx

    Friday, September 13, 2013 11:36 PM
  • User1119347574 posted

    Hi No use after reading that............same issue for me

    Saturday, September 14, 2013 12:08 AM
  • User1143442848 posted

    Hi,

    According to your description, the crystal report only displayed the first row but the procedure returned more than one row.

    Firstly, I suggest you set a breakpoint to check if the stored procedure returns the right DataSet or not and the one row showed in the report is included in the DataSet or not.

    Secondly, please try to refer to the code snippet below and I think you will find the solution. Note: the code is in vb.net, but it can easily be converted to C#.

    Imports CrystalDecisions.CrystalReports.Engine
     Imports CrystalDecisions.Shared
     Imports System.Data
     Imports System.Data.SqlClient
    
    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
             ConfigureReport()
         End Sub
    
    Private Sub ConfigureReport()
             If Not Page.IsPostBack Then
                 Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
                 myConnectionInfo.DatabaseName = DatabaseName
                 myConnectionInfo.UserID = userid
                 myConnectionInfo.Password = password
                 Dim ReportPath As String = Server.MapPath("YourReport.rpt")
                 ReportViewer1.ReportSource = ReportPath
    
                Dim field1 As ParameterField = Me.ReportViewer1.ParameterFieldInfo(0)
                 Dim field2 As ParameterField = Me.ReportViewer1.ParameterFieldInfo(1)
                 Dim val1 As New ParameterDiscreteValue()
                 Dim val2 As New ParameterDiscreteValue()
                 val1.Value = "value1"
                 val2.Value = "value2"
                 field1.CurrentValues.Add(val1)
                 field2.CurrentValues.Add(val2)
    
                SetDBLogonForReport(myConnectionInfo)
             End If
     End Sub
    
    Private Sub SetDBLogonForReport(ByVal myConnectionInfo As ConnectionInfo)
             Dim myTableLogOnInfos As TableLogOnInfos = ReportViewer1.LogOnInfo()
             For Each myTableLogOnInfo As TableLogOnInfo In myTableLogOnInfos
                 myTableLogOnInfo.ConnectionInfo = myConnectionInfo
             Next
         End Sub
    

    More explaination about the code please try to refer to the link below:

    # Connecting a stored procedure to a crystal report

    http://forums.asp.net/t/1935509.aspx

     

    Here is an article about using stored procedures to create crystal report:

    # using stored procedures to create crystal report

    http://www.pdssoftware.com/newsletter/mar07/page6.htm

     

    If you need more assistance, please feel free to let me know. 

    If possible, please try to post some more information in order to get more supports in a better way.

    Best Regards,

    Lisa Zhang

    Sunday, September 15, 2013 10:42 PM
  • User1786833724 posted

    Please make sure that you're sticking the fields are in details and not in headers section. Please have a look at these screen shots :

    https://filetea.me/t1svM70euz2RJyrmLLsUxPmng
    https://filetea.me/t1sN8Cat4lMTxyXTR3JnOojhA

    You may want to put  a breakpoint when you're getting results to make sure that the query does return the results

    protected void Page_Load(object sender, EventArgs e)
    		{
    			
    			DataTable tblOrderDetail = new DataTable("OrderDetail");
    			SqlCommand commnad = new SqlCommand("[dbo].[CustMultiOrdersDetail]");
    			commnad.CommandType = CommandType.StoredProcedure;
    			commnad.Parameters.Clear();
    			commnad.Parameters.Add(new SqlParameter("OrderID", "10643,10692,10702,10835,10952"));
    			ReportHelper.GetQueryResultFromNorthwind(ref commnad, ref tblOrderDetail);
    
                            //breakpoint on next line to see if 'tblOrderDetail' has got value
    			
    			CrystalReport1 objReport = new CrystalReport1();
    			ReportDocument doc = new ReportDocument();
    
    			objReport.SetDataSource(tblOrderDetail);
    			CrystalReportViewer1.ReportSource = objReport;
    			CrystalReportViewer1.RefreshReport();
    			//objReport.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Page.Response, true, "Test PDF.pdf");
    			objReport.ExportToDisk(ExportFormatType.PortableDocFormat, "C:\\Data\\Testy.pdf");
    			
    		}


    Monday, September 16, 2013 2:05 AM