Passing Log In user id at run time using .rdlc and Report Viewer. RRS feed

  • Question

  • Hello...everyone...

    I have to generate report from the Oracle database using .rdlc on Visual Studio 2005. All data will be extracted from database View. In the rdlc file, I have set the report layout and assigned the fields by using the dataset.
    Each column in dataset is assigned to a respective textbox on the rdlc file.
    When it runs, the report is correctly generated from the database.

    However, there is one textbox in the rdlc file where I need to set the Log In User ID at run time.
    At run time, it will show the log in User's name. I'll get the log in user id with Session("UserID"). However, I have no idea on how to pass this on the specific place of the page. I'm using, oracle 11g on visual studio 2005. I'm new to this report viewer. I'm using local report.

    Can anyone help me on this? Thank you.

    Thursday, August 20, 2009 1:51 AM

All replies

  • Hi,
      Create one parameter let say USERID and bind the report's textbox with this parameter.
    after that call your report something like following way:

    Imports Microsoft.Reporting.WebForms

     Private Sub ShowCustomReport()
    Dim pInfo As ReportParameterInfoCollection
     Dim paramList As New Generic.List(Of ReportParameter)

    ReportViewer.ServerReport.ReportPath = "/ReportPart/ReportName"
                        paramList.Add(New ReportParameter("USERID", Session.Item("USERID").ToString(), False))
                        pInfo = ReportViewer.ServerReport.GetParameters()

        End Sub

    Hope it will help you....

    Aftab Ansari
    • Marked as answer by Beginner-Zero Friday, August 21, 2009 2:21 AM
    • Unmarked as answer by Beginner-Zero Friday, August 21, 2009 2:23 AM
    • Proposed as answer by Aftab Ansari Tuesday, September 1, 2009 12:50 PM
    Thursday, August 20, 2009 6:30 AM
  • Thank you.

    It helps a lot... :)

    As I'm using Local Report, I just changed to Local Report.

    SetParameters is enough...After that add the datasource and it's working fine.  :D Thanks a lot!


    Friday, August 21, 2009 2:21 AM