Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to get two table or method using single reportviewer..

C#
public void bill()
      {
          try
          {
           

              ReportViewer1.LocalReport.DataSources.Clear();
              ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", DateWiseServiceData()));
              
              ReportViewer1.LocalReport.ReportPath = HttpContext.Current.Server.MapPath("~/Admin/Report/Jobcard.rdlc");
            //  ReportViewer1.LocalReport.Refresh();
              //Button1.Visible = true;

          }
          catch (Exception objException)
          {
              //ExceptionManager.ShowException(objException, this.ToString(), MethodInfo.GetCurrentMethod().Name);
              //objException = null;
          }
          finally
          {

          }

 private DataTable DateWiseServiceData()
        {
            try
            {
                if (conn.State == ConnectionState.Open)
                    conn.Close();
                conn.Open();
                //string startDate = txtStartDate.Text;

                //startDate = startDate + " 00:00";
                //string endDate = txtEndDate.Text;
                //endDate = endDate + " 23:59";
                // Create a Command  
               
                 
                SqlDataAdapter SqlDa = new SqlDataAdapter( "select jobcard_creation.jobcard_no,jobcard_creation.vehicle_no,jobcard_creation.vehicle_model,jobcard_creation.date, jobcard_staff.staff_name, "
                     + "  jobcard_creation.delivery_date,jobcard_creation.total_days,vehicle_type.vehicle_name,Job_type.jobtype_name from jobcard_creation "
                    + " left outer join vehicle_type on jobcard_creation.department_id=vehicle_type.vehicle_id   left outer join Job_type on job_type.jobtype_id=jobcard_creation.job_type  "
                    + " left join jobcard_staff on jobcard_staff.jobcard_id=jobcard_creation.jobcard_id  where "
                    + " jobcard_creation.jobcard_id='" + txtJobCardId.Text + "' and jobcard_creation.type='N' and jobcard_staff.type='N' ", conn);



               //SqlDataAdapter SqlDa1 = new SqlDataAdapter("select isnull(describtion,'') as describtion from jobcard_work_description where jobcard_id='" + txtJobCardId.Text + "' ",conn);
              
                DataSet1.jobcardDataTable InvoiceBill = new DataSet1.jobcardDataTable();
                //DataSet1.InvoiceDataTable InvoiceBill = new DataSet1.InvoiceDataTable();
                //DataSet1.Jobcard1DataTable InvoiceBill = new DataSet1.Jobcard1DataTable();
               

              
               
                //SqlDa1.Fill(dtble1);
                

               


                SqlDa.Fill(InvoiceBill);
              //  SqlDa1.Fill(InvoiceBill);
                return InvoiceBill;

                // SqlCommand SqlComm1 = new SqlCommand();
                //SqlComm1.Connection = conn;
                //SqlComm1.CommandType = CommandType.Text;
                //SqlComm1.CommandText = "select describtion from jobcard_work_description where jobcard_id='" + txtJobCardId.Text + "'";
                //DataSet1.InvoiceDataTable InvoiceBill1 = new DataSet1.InvoiceDataTable();
                //SqlDataAdapter SqlDa1 = new SqlDataAdapter(SqlComm);
                //SqlDa1.Fill(InvoiceBill1); // Fill Data in NorthwindDataSet Object.  

                //return InvoiceBill1;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Posted
Updated 20-May-15 3:50am
v2
Comments
Richard Deeming 20-May-15 10:02am    
Your code is still vulnerable to SQL Injection[^].

NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.

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