Click here to Skip to main content
15,667,355 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I write the following code in 4.0 web application.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public partial class SimpleCrystal1 : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
ReportDocument rptDoc = new ReportDocument();
dsTestCrystal ds = new dsTestCrystal();
DataTable dt = new DataTable();
dt.TableName = "Users";
dt = getAllOrders().Tables[0];
CrystalReportViewer1.ReportSource = rptDoc;
public DataSet getAllOrders()
string sqlCon = ConfigurationManager.AppSettings["conStr1"].ToString();
SqlConnection Con = new SqlConnection(sqlCon);
SqlCommand cmd = new SqlCommand();
DataSet ds = null;
SqlDataAdapter adapter;
cmd.CommandText = "getAllOrders";
cmd.CommandType = CommandType.StoredProcedure;

cmd.Connection = Con;
ds = new DataSet();
adapter = new SqlDataAdapter(cmd);
adapter.Fill(ds, "Users");
catch (Exception ex)
throw new Exception(ex.Message);
if (Con.State != ConnectionState.Closed)
return ds;
Updated 1-Dec-13 21:21pm
Surendrasinh Rathod 4-Dec-13 7:32am    
Hi,Nan Lae Pyone,I am not sure that this can help you or not.But my first question will be have you Designed Crystal report correctly.Because without design Crystal it wouldn't display data.

1 solution

Ensure you get data in your DataSet in runtime.
Here possible solutions for this issue.
Crystal Reports: Avoiding Blank Pages[^]
Crystal reports - Mysterious blank pages[^]
Crystal Report Blank / Empty / Not Displaying. No On-Screen Error, But Event Log ‘ConfigurationErrorsException’ Received[^]

dt.TableName = "Crystal Report Example";
Not a good name for a DataTable. Make sure your Report's Table name & this DataTable name are same, if not same then do changes & try again. Also check the same for DataSet(both report & code). Try again.

Display data in crystal reports[^]
Share this answer
Nan Lae Pyone 2-Dec-13 2:55am    
dataset and datatable not empty. it is sure. the above 3 links still not a solution for me.
thatraja 2-Dec-13 3:00am    
Check updated answer
Nan Lae Pyone 2-Dec-13 5:20am    
Just give possible solution. what mean "check updated answer"? please don't useless comment like this.
thatraja 2-Dec-13 5:26am    
In my answer, Already I have mentioned the words 'possible solutions'(which means possibly instead of probably).
FYI In past, those links helped bunch of people who faced similar issues.
/*what mean "check updated answer"? */
I have mentioned the 'EDIT' to separate my revision.
/*please don't useless comment like this.*/
That's your opinion.

Besides, it's my mistake to post answer without asking more details about the issue. In future, I'll keep this in my mind.

Anyway I could help you if you give me more details about your issue. Did you try what I have said in my updated answer?
Nan Lae Pyone 2-Dec-13 23:46pm    
Sorry for my word. I already tried. still problem. not show any error message and not show data in crystal report viewer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900