1
Answer

Problem with Crystal Report with Dataset Using Visual Studios 2008.

Rajesh Kumar

Rajesh Kumar

12y
1.5k
1

Good Morning,

This is Rajesh, am having a problem with Crystal Report in ASP.NET with C# using Visual Studios 2008. That is

1.       I have created a DataSet and drag one "View" from Solution Explorer.

2.       Next I have created one Crystal Report add data from Project data -> ADO.NET Datasets -> "View".

3.       Then created a webform add a TextBox for enter date (I want report based on date field DOP on database) and a button called "BtnShow" and Witten code under the button is as follows.

protected void BtnShow_Click(object sender, EventArgs e)

      {

        SqlConnection cn = new SqlConnection();

  cn.ConnectionString =    ConfigurationManager.ConnectionStrings["DBConn"].ConnectionString;

        SqlDataAdapter adp = new SqlDataAdapter("SELECT EMP_ID, EMP_NAME, BANK_NAME, AC_NO, DOP FROM VIEW WHERE DOP = '" +Convert.ToDateTime(TxtDate.Text)+ "'", cn);

        DataSet DS = new DataSet();

        adp.Fill(DS);

        ReportDocument cr = new ReportDocument();

        cr.Load("C:\\Report Path Here\\Report.rpt");

        cr.SetDataSource(DS.Tables[0]);

        CrystalReportViewer1.ReportSource = cr;

        CrystalReportViewer1.RefreshReport();

    }

4.  When I run the project it working perfectly alright for different date which was in database.

5.  But the problem is when I attempt to export or print or any option in the report header (Default options), it asks the login details. If I enter correct details then it didn't show anything, It shows only login page again and again.

6.  What to do?

7.  Kindly help me. Thanks.

Answers (1)