locked
Writing SQL Query to load the data into RDLC Reports! RRS feed

  • Question

  • Hi folks!

    Is there any way that I could pass the data by using SQL Query or applying query to the dataset which is used in my .rdlc file?
    For example: SELECT * FROM EmployeeTable WHERE EmployeeID='"+txtEmployee.Text.Trim()+"'.

    Any suggestions would be appreciated.

    Thanks and regards,
    V
    Friday, September 4, 2009 12:29 PM

Answers

  • What do you mean pass? Is you RDLC report wrapped in a .Net assembly or a COM object? Just execute the query using SqlCommand, SqlConnection, and SqlDataAdapter objects ( OleDb objects if you are not using Sql Server ) and fill your dataset/datatable.

    From there you can either bind the dataset/datatable to the report's data source property or if the report cannot interface with .Net objects you can serialize the dataset/datatable to an XML file for your report to comsume.
    • Marked as answer by Harry Zhu Friday, September 11, 2009 2:35 AM
    Friday, September 4, 2009 1:10 PM

All replies

  • you can attain the items to some constants in you code then write them to the rdlc file

     

     

     

    string emp = String.Empty; 
    emp = txtEmployeeText.ToString().Trim();
    
    
    


    then you can use emp to write to .rdlc

    Friday, September 4, 2009 1:08 PM
  • You can bind the RDLC to a object datasource and map the object datasource to a static function that returns type Employee, and pass the fileters.
    <asp:ObjectDataSource 
      ID="EmployeeDetailsObjectDataSource" 
      runat="server" 
      TypeName="urNamespace.Employee" 
      SelectMethod="GetEmployee" 
       <SelectParameters>
        <asp:Parameter Name="EmployeeID" />  
      </SelectParameters>
      <InsertParameters>
    </asp:ObjectDataSource>
    
    Alternativly, you can use Datasets to bind it to report
    Friday, September 4, 2009 1:09 PM
  • What do you mean pass? Is you RDLC report wrapped in a .Net assembly or a COM object? Just execute the query using SqlCommand, SqlConnection, and SqlDataAdapter objects ( OleDb objects if you are not using Sql Server ) and fill your dataset/datatable.

    From there you can either bind the dataset/datatable to the report's data source property or if the report cannot interface with .Net objects you can serialize the dataset/datatable to an XML file for your report to comsume.
    • Marked as answer by Harry Zhu Friday, September 11, 2009 2:35 AM
    Friday, September 4, 2009 1:10 PM
  • Hi! Michale can u show me a code example of above reply! I only want to pass sql query to rdlc report to load data dynamically. I've used ur above suggestion without any success. would appreciate any help here.
    www.sudokuonweb.com
    Saturday, December 5, 2009 8:29 PM