Results 1 to 7 of 7

Thread: [RESOLVED] Dynamic rdlc report

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2011
    Posts
    123

    Resolved [RESOLVED] Dynamic rdlc report

    Hello to all.

    I've been googling around to find a way to dynamically assign a DataSet to an rdlc report but i was unable to find a clear method to do it.
    Does anyone know if there is a way? I end up trying to use this method because i also found no way of adding parameters to the rdlc report. The VS documentation is vague on this issue...

    Thanks a lot in advance for any kind help.

    Octavio

  2. #2
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Dynamic rdlc report

    When you are in the report designer, go to the Report menu. You will see the Report Parameters option. That lets you use parameters in the Report. You will also see the Data Sources option. This allows you to bind tables, and fields to the Report. Then, when you have a ReportViewer on your Form, in code, you can access the ReportViewer.LocalReport.DataSources property, and you can set the parameters using the ReportViewer.LocalReport.SetParameters property.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2011
    Posts
    123

    Re: Dynamic rdlc report

    Hello.

    Beautiful! This means that i can use the Load event of the Report Viewer to build the data source using SQL and assign the datasource to the report, right?

    If this is correct some of my hair will still remain at the top of my head...

    Octavio.

  4. #4
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Dynamic rdlc report

    Yup. That's what I do.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Apr 2011
    Posts
    123

    Re: Dynamic rdlc report

    Yeahhh! Great!
    Thanks a lot!

  6. #6
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    993

    Re: [RESOLVED] Dynamic rdlc report

    hello, can you upload a sample?
    Programming is all about good logic. Spend more time here


    (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Apr 2011
    Posts
    123

    Re: [RESOLVED] Dynamic rdlc report

    Hi.

    Don't know if this is what you're looking for but the following code deletes the content of a table and populates it again. Following the report is printed with the result of the query depending on the parameter values.

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    If Me.TextBox1.Text = "" Or IsNumeric(Me.TextBox1.Text) = False Then
    Return
    End If
    Dim MyConn As ADODB.Connection
    Dim MyRecSet As ADODB.Recordset

    Dim DelSql As String
    Dim tmpSQL As String

    MyConn = New ADODB.Connection
    MyRecSet = New ADODB.Recordset
    MyConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\boxus\Geral\Dados\UTLT.accdb;Persist Security Info = False"
    MyConn.Open()
    Try
    DelSql = "DELETE FROM UNICRE_REPORT_COMM"
    MyConn.Execute(DelSql)
    tmpSQL = "INSERT INTO UNICRE_REPORT_COMM (C_NAME, TRX_AMNT, ACT, BUY_L_NAME, BUY_F_NAME, BUYER_MAIL, USER_LOG, SH_MESSAGE, TRX_DATE, AUT_NUMBER, DT_FECHO, TRXS_TOTAL, COMM, UTIL, CC_NOME, CC_LOCAL, CC_NOME_LOGIN, CC_OFFICE, CC_DEP) SELECT A.CORPORATE_NAME, A.TRANSACTION_AMOUNT, A.ACTION, A.BUYER_LAST_NAME, A.BUYER_FIRST_NAME, A.BUYER_EMAIL, A.USER_LOGIN, A.SHORT_MESSAGE, A.TRANSACTION_DATE, A.AUTORIZATION_NUMBER, B.DATA_FECHO, B.TRX_TOTAL, B.COMISSAO, B.UTILIZADOR, C.NOME, C.LOCALIZACAO, C.NOME_LOGIN, C.OFFICE, C.DEP FROM FECHO_UNICRE A, FECHO_UNICRE_REP B, UNICRE_CC C WHERE (B.DATA_FECHO = A.TRANSACTION_DATE AND C.NOME_LOGIN = A.USER_LOGIN)"
    MyConn.Execute(tmpSQL)
    Dim rs1 As ADODB.Recordset
    Dim SomaSql As String
    SomaSql = "SELECT SUM(TRX_AMNT) FROM UNICRE_REPORT_COMM"
    rs1 = New ADODB.Recordset
    Call rs1.Open(SomaSql, MyConn)
    Me.TextBox2.Text = rs1.Fields(0).Value
    MyConn.Close()
    Dim p1 As New ReportParameter("teste", Val(Me.TextBox1.Text))
    Dim p2 As New ReportParameter("soma", Val(Me.TextBox2.Text))
    Unicre_Report_Comm.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {p1, p2})
    Unicre_Report_Comm_SR.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {p1, p2})
    Me.Close()
    Catch ex As Exception
    MsgBox(ex.Message).ToString()
    End Try
    Unicre_Report_Comm.Show()
    Unicre_Report_Comm_SR.Show()
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width