How can I create a report using 5 tables of SQL Server?
I've got table master that stores the data. And others child tables, where i keep the data. In the child tables I have any data to the same data in masters. So, I want to select data by group.

Sorry for english.

Recommended Answers

All 6 Replies

That mode I know.
How can i do to show "customer1" once only without repeat.

I solved the problem. In Report I created a list and inside I put data sources that I wanted. And for each table, I inserted Table from Report Items.

Thanks.

use sql DISTINCT

Hi, Solved with ReportViewer:

Imports System.Data.SqlClient
Imports Microsoft.Reporting.WinForms


Public Class Form1

    Dim OsSelecionada As String
    Dim connString As String = "Data Source=PREPRESS;Initial Catalog=Testes;User Id=sa;Password=Drupa2000;"

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        OsSelecionada = InputBox("Digite Os")

        Try
            With Me.ReportViewer1.LocalReport
                ' Caminho para o relatório 
                .ReportPath = Application.StartupPath & "\..\..\Report1.rdlc"
                .DataSources.Clear()
            End With
            ' ---------------------------------------------------- 
            ' Datasource para o relatório principal
            ' ---------------------------------------------------- 
            Dim SQL As String = "SELECT * FROM TabItensOs WHERE OrderId = '" & OsSelecionada & "'"
            Using da As New SqlDataAdapter(SQL, connString)
                Using ds As New DataSet
                    da.Fill(ds, "TabItensOs")
                    ' É preciso usar o mesmo nome como foi de definido  
                    Dim rptDataSource As New ReportDataSource("dsReport_TabItensOS", ds.Tables("TabItensOs"))
                    Me.ReportViewer1.LocalReport.DataSources.Add(rptDataSource)

                End Using
            End Using
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

        Me.ReportViewer1.RefreshReport()

        AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf SubReportTabOrdemServico
        AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf SubReportTabAcabamento

    End Sub
    Sub SubReportTabOrdemServico(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)

        Try
            Dim SQL As String = "SELECT * FROM TabOrdemServico WHERE OrderId = '" & OsSelecionada & "'"
            Using da As New SqlDataAdapter(SQL, connString)
                Using ds As New DataSet
                    da.Fill(ds, "TabOrdemServico")
                    Dim rptDataSource As New ReportDataSource("dsReport_TabOrdemServico", ds.Tables("TabOrdemServico"))
                    e.DataSources.Add(rptDataSource)
                End Using
            End Using

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.