简体   繁体   中英

Creating Crystal Report in asp.net c# with SQL Server 2008 R2

I am doing dispatch management system. There i want a crystal report that will accept a date from a textbox or dropdown list and according to that date i need to display all the data in that day as a report.

I am using Visual Studio 2005 and SQL Server 2008 R2. My database name is letter and table name for generating report is inward.

This table has columns

id, dispatchno, dispatchdate, fromname, fromaddress, subject, lettertype, letterno, remarks where subject, lettertype, letterno may have null values.

I want to generate report with dispatchno.dispatchname, fromname and from address together in a column also subject and remarks together.

In record selection formula I can select the dates, but will it be possible only for that day. What I need is to select a date from textbox or dropdown lists and I need to display report for that day. I used the formula {inward.fromname}+","+{inward.fromaddress} for joining fromname and fromadrress. It works fine. But when I joining subject and remarks using the formula IIF(IsNull({inward.subject}), "" , {inward.remarks} & ",") I am getting blank. Here subject having null values.

I use the code in reports.aspx.cs page like..

using CrystalDecisions.CrystalReports.Engine;

using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page {

protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
    ReportDocument cryRpt = new ReportDocument();
    cryRpt.Load(Server.MapPath("CrystalReport.rpt"));
    CrystalReportViewer1.ReportSource = cryRpt; 
}

}

I got the answer for avoiding null value while combining two fields of the data table. Code is ,

If IsNull({inward.subject}) then "NULL" +',' +{inward.remarks} else {inward.subject} + ', ' + {inward.remarks}

Still having problem to display crystal report according to the date selected from the textbox. I need to display like this. display crystal report where the dispatch date = value accept from the textbox.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM