Data Source with ReportViewer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Xpeppe

    #1

    Data Source with ReportViewer

    Hy, i read the article in msdn2

    Using a Database Data Source with the ReportViewer Windows Forms Control in
    Local Processing Mode

    But i don want to use the designer assosation to the report,
    i want to define by code (at run time) the report and the
    data source to be display.

    example :

    i have two table on sqlclient db file (anagrafica and pratica)
    and i have two report (rpt_anagrafica .rdlc and rpt_pratica.rdl c)

    in a form a have two button, one for visualize the first repor (whit his
    data anagrafica) and
    one to visualize the second report (whit his data pratica) ,
    when run the application i want to decide what report to be visualize.

    for this i don't now what is the metod
    have yuo any example ?

    I hope explain correctly (sorry for my english) thank's.


  • Pieter

    #2
    Re: Data Source with ReportViewer

    Hi,

    I don't know if I understood your suestion very good, but I thought you
    wanted to chose at runtime the report to show? I'm using myself a solution
    like this: One form, that contains one reportviewer, and I'm using the same
    to show all my reports (based on a parameter).

    This is my code:

    'This comes in the form-load
    Me.rpvwReport.P rocessingMode =
    Microsoft.Repor ting.WinForms.P rocessingMode.R emote
    '"ReportServerU rl"="http://MyServer/reportserver200 5"
    Me.rpvwReport.S erverReport.Rep ortServerUrl = New
    System.Uri(Syst em.Configuratio n.Configuration Manager.AppSett ings.Get("Repor tServerUrl"),
    System.UriKind. Absolute)


    'method to show a given report (defines buy my variabel Me.m_ReportType )
    Public Overridable Sub Fill()
    Dim colPrm As New Generic.List(Of ReportParameter )
    Dim prm As ReportParameter
    Dim clsRep As clsReport = Nothing

    Try
    Select Case Me.m_ReportType 'select which report to show
    (currently only one)
    Case enumReportType. RepDemandeDeCot ation
    'charge le rapport de la DemandeDeCotati on
    clsRep =
    clsWorkSpace.My WorkSpace.GetRe portFromReportN ame("DemandeDeC otation")
    prm = New ReportParameter ("intCotationID ",
    Me.m_Document.P rimaryKey)
    colPrm.Add(prm)
    prm = New ReportParameter ("intPersonneID ",
    Me.cmbResponsab le.SelectedValu e.ToString)
    colPrm.Add(prm)
    End Select
    '52RE6_001.pdf"
    Catch ex As Exception
    ErrorMessage(ex , "Select Case Me.m_ReportType ")
    End Try

    Try
    If clsRep Is Nothing Then
    'problem
    MessageBox.Show ("Le rapport ne peut pas être trouvé sur le
    serveur.", "Pas de rapport", MessageBoxButto ns.OK, MessageBoxIcon. Error)
    Else
    Me.rpvwReport.S erverReport.Rep ortPath = clsRep.ReportPa th
    Me.rpvwReport.S erverReport.Set Parameters(colP rm)
    Me.rpvwReport.R efreshReport()
    End If
    Catch ex As Exception
    ErrorMessage(ex , "SetParameters" )
    End Try

    Me.HasLoaded = True
    End Sub



    "Xpeppe" <xpeppe@libero. it> wrote in message
    news:a9sUf.4551 6$PR2.826087@tw ister2.libero.i t...[color=blue]
    > Hy, i read the article in msdn2
    >
    > Using a Database Data Source with the ReportViewer Windows Forms Control
    > in Local Processing Mode
    >
    > But i don want to use the designer assosation to the report,
    > i want to define by code (at run time) the report and the
    > data source to be display.
    >
    > example :
    >
    > i have two table on sqlclient db file (anagrafica and pratica)
    > and i have two report (rpt_anagrafica .rdlc and rpt_pratica.rdl c)
    >
    > in a form a have two button, one for visualize the first repor (whit his
    > data anagrafica) and
    > one to visualize the second report (whit his data pratica) ,
    > when run the application i want to decide what report to be visualize.
    >
    > for this i don't now what is the metod
    > have yuo any example ?
    >
    > I hope explain correctly (sorry for my english) thank's.
    >[/color]


    Comment

    • Cor Ligthert [MVP]

      #3
      OT

      Pieter,

      Ben jij een Waal/van Brussel?

      Maybe did you it earlier that I did not see it, otherwise,

      Nice to see you starting anwering here questions.

      :-)

      Cor

      "Pieter" <pietercoucke@h otmail.com> schreef in bericht
      news:udfZNdlTGH A.4452@TK2MSFTN GP12.phx.gbl...[color=blue]
      > Hi,
      >
      > I don't know if I understood your suestion very good, but I thought you
      > wanted to chose at runtime the report to show? I'm using myself a solution
      > like this: One form, that contains one reportviewer, and I'm using the
      > same to show all my reports (based on a parameter).
      >
      > This is my code:
      >
      > 'This comes in the form-load
      > Me.rpvwReport.P rocessingMode =
      > Microsoft.Repor ting.WinForms.P rocessingMode.R emote
      > '"ReportServerU rl"="http://MyServer/reportserver200 5"
      > Me.rpvwReport.S erverReport.Rep ortServerUrl = New
      > System.Uri(Syst em.Configuratio n.Configuration Manager.AppSett ings.Get("Repor tServerUrl"),
      > System.UriKind. Absolute)
      >
      >
      > 'method to show a given report (defines buy my variabel Me.m_ReportType )
      > Public Overridable Sub Fill()
      > Dim colPrm As New Generic.List(Of ReportParameter )
      > Dim prm As ReportParameter
      > Dim clsRep As clsReport = Nothing
      >
      > Try
      > Select Case Me.m_ReportType 'select which report to show
      > (currently only one)
      > Case enumReportType. RepDemandeDeCot ation
      > 'charge le rapport de la DemandeDeCotati on
      > clsRep =
      > clsWorkSpace.My WorkSpace.GetRe portFromReportN ame("DemandeDeC otation")
      > prm = New ReportParameter ("intCotationID ",
      > Me.m_Document.P rimaryKey)
      > colPrm.Add(prm)
      > prm = New ReportParameter ("intPersonneID ",
      > Me.cmbResponsab le.SelectedValu e.ToString)
      > colPrm.Add(prm)
      > End Select
      > '52RE6_001.pdf"
      > Catch ex As Exception
      > ErrorMessage(ex , "Select Case Me.m_ReportType ")
      > End Try
      >
      > Try
      > If clsRep Is Nothing Then
      > 'problem
      > MessageBox.Show ("Le rapport ne peut pas être trouvé sur le
      > serveur.", "Pas de rapport", MessageBoxButto ns.OK, MessageBoxIcon. Error)
      > Else
      > Me.rpvwReport.S erverReport.Rep ortPath = clsRep.ReportPa th
      > Me.rpvwReport.S erverReport.Set Parameters(colP rm)
      > Me.rpvwReport.R efreshReport()
      > End If
      > Catch ex As Exception
      > ErrorMessage(ex , "SetParameters" )
      > End Try
      >
      > Me.HasLoaded = True
      > End Sub
      >
      >
      >
      > "Xpeppe" <xpeppe@libero. it> wrote in message
      > news:a9sUf.4551 6$PR2.826087@tw ister2.libero.i t...[color=green]
      >> Hy, i read the article in msdn2
      >>
      >> Using a Database Data Source with the ReportViewer Windows Forms Control
      >> in Local Processing Mode
      >>
      >> But i don want to use the designer assosation to the report,
      >> i want to define by code (at run time) the report and the
      >> data source to be display.
      >>
      >> example :
      >>
      >> i have two table on sqlclient db file (anagrafica and pratica)
      >> and i have two report (rpt_anagrafica .rdlc and rpt_pratica.rdl c)
      >>
      >> in a form a have two button, one for visualize the first repor (whit his
      >> data anagrafica) and
      >> one to visualize the second report (whit his data pratica) ,
      >> when run the application i want to decide what report to be visualize.
      >>
      >> for this i don't now what is the metod
      >> have yuo any example ?
      >>
      >> I hope explain correctly (sorry for my english) thank's.
      >>[/color]
      >
      >[/color]


      Comment

      • Pieter

        #4
        Re: OT

        "Cor Ligthert [MVP]" <notmyfirstname @planet.nl> wrote in message
        news:O8hLgklTGH A.4384@tk2msftn gp13.phx.gbl...[color=blue]
        > Pieter,
        >
        > Ben jij een Waal/van Brussel?[/color]

        Hi Cor,
        Actually I'm from Gent, so I'm a Vlaming :-) But I do work for a
        French-speaking Belgium/French Company, with parts in Africa. So the
        official language in the company is French :-) I know I sometimes post
        French comments in my code, or use French names. My apologizes, hehe. I'd
        rather prefer too that Dutch was the offical world-language ;-)
        [color=blue]
        > Maybe did you it earlier that I did not see it, otherwise,
        >
        > Nice to see you starting anwering here questions.
        >[/color]

        I did alreaddy answer a lot of questions before, but only if I do have some
        real experience in the domain, and off course only when I know the answer,
        hehe. I have to admit that I could answer a lot more questions, but most of
        the time somebody else (like you) did it alreaddy before I see them :-)
        [color=blue]
        > :-)
        >
        > Cor[/color]


        Comment

        Working...