locked
Itz my complete code for your Refrence Please help me in this...? where im wrong? RRS feed

  • Question

  • User-1934381873 posted


    This is my  method to bind table in crystal Report...

    and  binding crystal report in my aspx page is as follows


    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="FuelConsumpRpt.aspx.cs" Inherits="FuelConsumpRpt" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
    <%@ Register Assembly="CrystalDecisions.Web, Version=10.2.3600.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>Fuel Consumption Report</title>
    <script language="javascript" type="text/javascript">
    // <!CDATA[
    function DIV2_onclick() {
    }
    // ]]>
    </script>
        <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"
            rel="stylesheet" type="text/css" />
        <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"
            rel="stylesheet" type="text/css" />
        <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"
            rel="stylesheet" type="text/css" />
        <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"
            rel="stylesheet" type="text/css" />
        <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"
            rel="stylesheet" type="text/css" />
    </head>
    <body>
        <form id="form1" runat="server" defaultbutton="Button1">
        <div>
            <div id="DIV1" onclick="return DIV1_onclick()" style="border-right: teal 1px dotted;
                border-top: teal 1px dotted; z-index: 102; left: 37px; border-left: teal 1px dotted;
                width: 856px; border-bottom: teal 1px dotted; ; top: 2px;
                height: 69px">
                <asp:Button ID="Button1" runat="server" BackColor="Transparent" BorderColor="Black"
                    BorderStyle="Solid" BorderWidth="1px" Font-Bold="True" Font-Names="Palatino Linotype"
                    Font-Size="12pt" ForeColor="Maroon" Height="55px" OnClick="Button1_Click" Style="z-index: 100;
                    left: 771px; background-image: url(images/037.png); ; top: 7px"
                    TabIndex="5" Text="Search" ValidationGroup="a" Width="57px" />
                <strong><span style="font-size: 24pt; color: #800000"></span></strong><span style="font-family: Palatino Linotype">
                    <span></span><span style="color: #660000"><span style="font-family: Times New Roman">
                        <span style="color: #000000">&nbsp;
                            <img src="images/MyDocumentFolder.png" style="font-size: 12pt; z-index: 109; left: 14px;
                                ; top: 5px" />
                        </span><span style="color: #000000"></span></span></span></span>
                <div id="DIV2" style="font-size: 12pt; z-index: 110; left: 82px; width: 259px; color: #000000;
                    font-family: Times New Roman; ; top: 20px; height: 32px; text-align: left" onclick="return DIV2_onclick()">
                    <span><span><span><span><span><span><span>
                    </span></span><span style="font-size: 16pt; color: teal; font-family: Palatino Linotype">
                        <strong>
                        Fuel Consumption Report</strong></span></span></span></span></span></span></div>
                <img src="images/dividerArt%20stright.jpg" style="font-size: 12pt; z-index: 111;
                    left: 343px; width: 1px; color: #000000; font-family: Times New Roman; ;
                    top: -64px; height: 133px" />
                <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Palatino Linotype"
                    Font-Size="12pt" ForeColor="Maroon" Style="z-index: 101; left: 416px; ;
                    top: 4px" Text="Enter From Date"></asp:Label>
                <asp:TextBox ID="TextBox1" runat="server" Style="z-index: 102; left: 546px; ;
                    top: 4px" TabIndex="1"></asp:TextBox>
                <img src="images/V.jpg" style="font-size: 12pt; z-index: 112; left: 347px; width: 65px;
                    font-family: Times New Roman; ; top: 0px; height: 61px" />
                <asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Names="Palatino Linotype"
                    Font-Size="12pt" ForeColor="Maroon" Style="z-index: 103; left: 416px; ;
                    top: 35px" Text="Enter To Date"></asp:Label>
                <asp:TextBox ID="TextBox2" runat="server" Style="left: 546px; ;
                    top: 35px" TabIndex="2"></asp:TextBox>
                &nbsp;&nbsp;
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox1"
                    ErrorMessage="Please Enter From Date" Font-Bold="True" Font-Names="@Meiryo" Font-Size="12pt"
                    SetFocusOnError="True" Style="z-index: 105; left: 745px; ;
                    top: 11px" ValidationGroup="a">*</asp:RequiredFieldValidator>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox2"
                    ErrorMessage="Please Enter To Date" Font-Bold="True" Font-Names="@Meiryo" Font-Size="12pt"
                    SetFocusOnError="True" Style="z-index: 106; left: 746px; ;
                    top: 42px" ValidationGroup="a">*</asp:RequiredFieldValidator>
                <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/cal.png" Style="z-index: 107;
                    left: 706px; ; top: 0px" />
                <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/cal.png" Style="left: 706px;
                    ; top: 35px" />
            </div>
            <div style=" left: 63px; width: 100px; ; top: 74px;
                height: 100px; z-index: 101;">
                <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="True"
                    DisplayGroupTree="False" HasToggleGroupTreeButton="False" Height="1039px" ReportSourceID="CrystalReportSource1"
                    Style="z-index: 58; left: 0px; ; top: 0px" Width="901px" />
                <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
                    <Report FileName="FuelConspRpt.rpt">
                        <Parameters>
                            <CR:ControlParameter ControlID="TextBox1" ConvertEmptyStringToNull="False" DefaultValue=""
                                Name="FD" PropertyName="Text" ReportName="" />
                            <CR:ControlParameter ControlID="TextBox2" ConvertEmptyStringToNull="False" DefaultValue=""
                                Name="TD" PropertyName="Text" ReportName="" />
                        </Parameters>
                    </Report>
                </CR:CrystalReportSource>
            </div>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
        
        </div>
            <cc1:calendarextender id="CalendarExtender1" runat="server" format="dd-MMM-yyyy"
                popupbuttonid="ImageButton1" targetcontrolid="TextBox1"></cc1:calendarextender>
            <cc1:calendarextender id="CalendarExtender2" runat="server" format="dd-MMM-yyyy"
                popupbuttonid="ImageButton2" targetcontrolid="TextBox2"></cc1:calendarextender>
            <asp:ValidationSummary ID="ValidationSummary1" runat="server" DisplayMode="List"
                Font-Bold="True" Font-Names="Palatino Linotype" Font-Size="10pt" ForeColor="Maroon"
                Style="z-index: 99; left: 729px; ; top: 77px" ValidationGroup="a" Width="165px" />
        </form>
    </body>
    </html>

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ConsumpRpt.aspx.cs" Inherits="ConsumpRpt" %>

    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

    <%@ Register Assembly="CrystalDecisions.Web, Version=10.2.3600.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>Consumption Report</title>

        <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"

            rel="stylesheet" type="text/css" />

        <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"

            rel="stylesheet" type="text/css" />

        <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"

            rel="stylesheet" type="text/css" />

        <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"

            rel="stylesheet" type="text/css" />

        <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"

            rel="stylesheet" type="text/css" />

    </head>

    <body>

        <form id="form1" runat="server" defaultbutton="Button1">

        <div>

            <div id="DIV1" onclick="return DIV1_onclick()" style="border-right: teal 1px dotted;

                border-top: teal 1px dotted; z-index: 102; left: 37px; border-left: teal 1px dotted;

                width: 856px; border-bottom: teal 1px dotted; ; top: 2px;

                height: 69px">

                <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="True"

                    DisplayGroupTree="False" HasToggleGroupTreeButton="False" Height="1039px" ReportSourceID="CrystalReportSource1"

                    Style="z-index: 58; left: 0px; ; top: 0px" Width="901px" />

                <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">

                    <Report FileName="ConspRpt.rpt">

                        <Parameters>

                            <CR:ControlParameter ControlID="TextBox1" ConvertEmptyStringToNull="False" DefaultValue=""

                                Name="FD" PropertyName="Text" ReportName="" />

                            <CR:ControlParameter ControlID="TextBox2" ConvertEmptyStringToNull="False" DefaultValue=""

                                Name="TD" PropertyName="Text" ReportName="" />

                        </Parameters>

                    </Report>

                </CR:CrystalReportSource>

            </div>

            <asp:ScriptManager ID="ScriptManager1" runat="server">

            </asp:ScriptManager>

        

        </div>

           

        </form>

    </body>

    </html>


    and my aspx.cs page as follows

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;

    public partial class ConsumpRpt : System.Web.UI.Page
    {
        ReportDocument crReportDocument = new ReportDocument();
        TableLogOnInfo crTableLogOnInfo = new TableLogOnInfo();
        ConnectionInfo crConnectionInfo = new ConnectionInfo();
        CrystalDecisions.CrystalReports.Engine.Database crDatabase;
        CrystalDecisions.CrystalReports.Engine.Tables crTables;
        CrystalDecisions.CrystalReports.Engine.Table crTable;

        protected void ConfigureCrystalReports()
        {
            string Server1 = ConfigurationManager.AppSettings["Server"];
            string user1 = ConfigurationManager.AppSettings["Userid"];
            string Password1 = ConfigurationManager.AppSettings["Password"];
            string DataBase = ConfigurationManager.AppSettings["DataBase"];

            crReportDocument.Load(Server.MapPath("ConspRpt.rpt"));

            crConnectionInfo.ServerName = Server1;
            crConnectionInfo.DatabaseName = DataBase;
            crConnectionInfo.IntegratedSecurity = false;
            crConnectionInfo.UserID = user1;
            crConnectionInfo.Password = Password1;

            crDatabase = crReportDocument.Database;
            crTables = crDatabase.Tables;

            foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
            {
                crTableLogOnInfo = crTable.LogOnInfo;
                crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                crTable.ApplyLogOnInfo(crTableLogOnInfo);
            }
            Session.Add("crystalreport29", crReportDocument);

        }
        protected void Page_Init(object sender, EventArgs e)
        {
            if (Session["crystalreport29"] == null)
            {
                ConfigureCrystalReports();
            }

            CrystalReportViewer1.ReportSource = Session["crystalreport29"];
            CrystalReportViewer1.RefreshReport();
        
        }

        protected void Page_Load(object sender, EventArgs e)
        {
        }
           
    }

    The Above is My Complete Code For your Reference:-

    1) My problem is on first time the above Report is loading very slow... why itz very slow on first time.. is that any mistake..?

    2) Let us consider i have one more report same like above..

    In my Picture i have two table now this two table has some 35000 Records...
    what my problem is i know it take lot of time to load report coz of large amount of data in table, so i need to set custom pagaing for my crystal report so that first it shows me last 10 records from table from the database and then again 10 like so on.. by this way it load very fast....

    Please help me to achieve this two points itz a importnant and very quick reply needed..
    Thank you






    Sunday, August 15, 2010 2:47 AM

All replies