0

it's confusing, see:

  1. 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.

  2. Dragged all field names from Datatable to Crystal report.

  3. 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 ?

Edited by HunainHafeez: code format

2
Contributors
1
Reply
5
Views
3 Years
Discussion Span
Last Post by LastMitch
0

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 ?

@HunainHafeez

I assuming you are still connected to the database even though you remove that code. That info is still in your table.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.