locked
Please Help i am not getting data on crystal report. RRS feed

  • Question

  • User-1868929400 posted

    Hi All,

    I trying to use crystal report in my visual studio 2012 ultimate edition.

    But , I am getting error as logon failed.

    So i use another turn around as below:

     
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using System.Configuration;
    using System.Data.SqlClient;
    using CrystalDecisions.CrystalReports.Engine;
    
    public partial class Default2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ReportDocument crystalReport = new ReportDocument();
            crystalReport.Load(Server.MapPath("~/CustomerReport.rpt"));
            RELEASEORDER dsCustomers = GetData("select * from ro");
            crystalReport.SetDataSource(dsCustomers);
            CrystalReportViewer1.ReportSource = crystalReport;
        }
    
    
        public RELEASEORDER GetData(string query)
        {
    
            string conString = ConfigurationManager.ConnectionStrings["riyodbdataConnectionString"].ConnectionString;
            SqlCommand cmd = new SqlCommand(query);
            using (SqlConnection con = new SqlConnection(conString))
            {
                using (SqlDataAdapter sda = new SqlDataAdapter())
                {
                    cmd.Connection = con;
    
                    sda.SelectCommand = cmd;
                    using (RELEASEORDER dsCustomers = new RELEASEORDER())
                    {
                        sda.Fill(dsCustomers, "RO");
                        return dsCustomers;
                    }
                }
            }
        
        
        }
    
    
    }
    
    
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="CS.aspx.cs" Inherits="CS" %>
    
    <%@ Register Assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
        Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="True"  Height="1202px" ReportSourceID="CrystalReportSource1"  ToolPanelWidth="200px" Width="1104px" />
            <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
                <Report FileName="CustomerReport.rpt">
                </Report>
            </CR:CrystalReportSource>
        </form>
    </body>
    </html>
    
    
    
    

    But here in this case after providing all the logon details i am getting blank in the dataset.

    I debugged  the code it runs till last statement  without error but i get blank in the dataset and i get blank sap crystal report with only headings of the columns.

    It is crossing all the statements  of the database connectivity but stll blank in the dataset even thought there is data in the table.

    Please help me as if i missing any thing in the code.

    Regards,

    Jayesh.(From India,Mumbai)

    Friday, May 9, 2014 6:38 AM

Answers

  • User-1868929400 posted

    I got the problem.

    The records i was fetching was containing one complete null row.

    So it was dividing the records in 2 data tables.

    And i was binding to one table which was having this null record.

    I removed the null row.

    And now crystal report is displaying properly without any error.

    Regards,

    Jayesh(From India,Mumbai).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 9, 2014 7:10 AM