Display RDLC Report using multiple DataSet (DataTables) in ASP.Net

Last Reply one year ago By pandeyism

Posted one year ago

Hello Sir,

I want to display the data in rdlc using join query rather than using multiple datasets.

protected void btn1_Click(object sender, EventArgs e)
{
    string selectName = DropDownList4.SelectedItem.Text;

    SqlCommand cmd2 = new SqlCommand("select * from service_schedule where preferred_name=@preferredname and rowstate=1", con);
    SqlCommand cmd3 = new SqlCommand("select * from care_service where preferred_name=@preferredname and rowstate=1", con);
    cmd2.Parameters.AddWithValue("@preferredname", selectName);
    cmd3.Parameters.AddWithValue("@preferredname", selectName);
    SqlDataAdapter da2 = new SqlDataAdapter(cmd2);
    SqlDataAdapter da3 = new SqlDataAdapter(cmd3);
    client_homescheduleDataSet dsCustomers2 = new client_homescheduleDataSet();
    da2.Fill(dsCustomers2, "service_schedule");
    client_careserviceDataSet dsCustomers3 = new client_careserviceDataSet();
    da3.Fill(dsCustomers3, "client_care_service");
    ReportViewer2.ProcessingMode = ProcessingMode.Local;
    ReportViewer2.LocalReport.ReportPath = Server.MapPath("~/agreement_homecareclient.rdlc");
    ReportDataSource datasource2 = new ReportDataSource("scheduleDataSet", dsCustomers2.Tables[0]);
    ReportDataSource datasource3 = new ReportDataSource("careserviceDataSet", dsCustomers3.Tables[0]);
    ReportViewer2.LocalReport.DataSources.Clear();
    ReportViewer2.LocalReport.DataSources.Add(datasource2);
    ReportViewer2.LocalReport.DataSources.Add(datasource3);
    ReportViewer2.LocalReport.EnableHyperlinks = true;
}
private scheduleDataSet GetData2(string query)
{
    SqlCommand cmd = new SqlCommand(query);
    SqlDataAdapter sda = new SqlDataAdapter();
    cmd.Connection = con;
    sda.SelectCommand = cmd;
    scheduleDataSet ds = new scheduleDataSet();
    sda.Fill(ds, "service_schedule");
    return ds;
}
private careserviceDataSet GetData3(string query)
{
    SqlCommand cmd = new SqlCommand(query);
    SqlDataAdapter sda = new SqlDataAdapter();
    cmd.Connection = con;
    sda.SelectCommand = cmd;
    careserviceDataSet ds = new careserviceDataSet();
    sda.Fill(ds, "care_service");
    return ds;
}

Thank you

Posted one year ago

Posted one year ago Modified on one year ago