Getting values from diiferent tables in a database and ahow in a single tablix of ReportViewer (.rdlc). RRS feed

  • Question

  • Hello,

    I am working on a billing software. I would like to generate an Invoice containing values from 3 different tables of a database.


            <WindowsFormsHost Height="504">
                <rv:ReportViewer x:Name="_reportViewer"/>

    Code Behind

            private DataTable GetEmployeeData()
                    // Open Sql Connection  
                    DataTable dt = new DataTable();
                    // Create a Command  
                    SqlCeCommand com5 = new SqlCeCommand("SELECT MAX(OrderID) AS Expr1 FROM Order_Details", con);
                    maxOrderID = (int)com5.ExecuteScalar();
                    SqlCeCommand com = new SqlCeCommand("SELECT Products_Master.ProductName, Order_Products.Quantity, Order_Details.TotalTax, Order_Products.Cost, Order_Details.Discount, Order_Details.TotalPrice FROM Order_Products INNER JOIN Order_Details ON Order_Details.OrderID = Order_Products.OrderID INNER JOIN Products_Master ON Products_Master.ProductCode = Order_Products.ProductCode WHERE (Order_Details.OrderID = '" + maxOrderID + "')", con);
                    SqlCeDataReader dr = com.ExecuteReader();

                    // Create instance of Northwind DataSetXSD  
                    //BillingDatabaseDataSet.Order_ProductsDataTable productsDT = new BillingDatabaseDataSet.Order_ProductsDataTable();

                    // Set a Data Commands  
                    SqlCeDataAdapter SqlDa = new SqlCeDataAdapter(com);

                    SqlDa.Fill(dt); // Fill Data in NorthwindDataSet Object.  

                    return dt;

                catch (Exception ex)
                    throw new Exception(ex.Message);

            private void ReportViewer_Load(object sender, EventArgs e)
                if (!_isReportViewerLoaded)

                    Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
                    BillingDatabaseDataSet dataset = new BillingDatabaseDataSet();


                    reportDataSource1.Name = "DataSet1"; //Name of the report dataset in our .RDLC file
                    reportDataSource1.Value = dataset.Order_Products;
                    this._reportViewer.LocalReport.ReportEmbeddedResource = "Billing.Report1.rdlc";


                    //fill data into Order_ProductsDataSet
                    BillingDatabaseDataSetTableAdapters.Order_ProductsTableAdapter salesOrderDetailTableAdapter = new BillingDatabaseDataSetTableAdapters.Order_ProductsTableAdapter();
                    salesOrderDetailTableAdapter.ClearBeforeFill = true;


                    _isReportViewerLoaded = true;

    But i am not able to add these custom values to my report viewer.

    I am using Visual Studio 2012, Sql Server Ce, WPF, C# for coding.

    Thursday, November 7, 2013 11:22 AM