it's confusing, see:
I added a dataset in app_code folder and then added a dummy datatable (field names similar to one in database), so it is visible to Crystal report in ADO.net datasets list.
Dragged all field names from Datatable to Crystal report.
Now as i added code to do in .aspx.cs and it's working perfectly.
protected void Page_Load(object sender, EventArgs e)
{fillin_cr(); } string conStr = WebConfigurationManager.ConnectionStrings["LoginDatabaseConnectionString"].ConnectionString; public void fillin_cr() { //DataSet2 ds = new DataSet2(); DataTable dt = new DataTable(); using(SqlConnection sqlCon = new SqlConnection(conStr)) using(SqlCommand sqlCom = new SqlCommand("select * from login", sqlCon )) using (SqlDataAdapter sda = new SqlDataAdapter(sqlCom)) { try { sda.Fill(dt); Response.Write("Filled"); //ds.Tables[0].Merge(dt); ReportDocument rd = new ReportDocument(); rd.Load(Server.MapPath("CrystalReport2.rpt")); rd.SetDataSource(dt); crViewer2.ReportSource = rd; Response.Write("ENDED"+ "<br/>"); } catch (Exception exc) { Response.Write("ERROR:"+ exc.Message); } }
But problem is that why it is working ? even i commented this line
ds.Tables[0].Merge(dt);
but still it's working, why ? names which i dragged are from another (dummy) table and the one i mentioned in code is another (though same field names) but i didn't merge and still it's working, why ?