ALIMENTAR UM SUB RELATORIO CR DO VS2008
nunca alimentei um sub relatorio entao to totalmente perdido
Citação:Private Sub frmRelatorioEmpresas_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
PreviewRelClientes(CarregarListaClientes(StrRelatorio))
End Sub
Private Sub PreviewRelClientes(ByVal oTable As DataTable)
[ô]
[ô]visualizar o relatório [Ô]rptCustomer.rpt[Ô] utilizando a função CarregarListaClientes()
[ô]
Try
[ô]1 passo: definindo o relatório a ser visualizado (ReportPath)
Dim crReportDocument As New Empresas
[ô]2 passo: definindo o DataSource do relatório
crReportDocument.SetDataSource(oTable)
[ô]3 passo: visualizando o relatório...
CRV1.DisplayGroupTree = False
CRV1.ReportSource = crReportDocument
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Public Function CarregarListaClientes(ByVal strCountryName As String) As DataTable
[ô]definindo a string de conexão do banco de dados
[ô]Dim strConexao As String = _
[ô]ConfigurationManager.ConnectionStrings([Ô]SQLServerCompact[Ô]).ToString
Dim strConexao As String = [Ô]Data Source=[Ô] & My.Application.Info.DirectoryPath & [Ô]\dados.sdf[Ô]
Dim oConn As New SqlCeConnection(strConexao)
Dim strSQL As New StringBuilder
Dim oTable As New DataTable()
Dim oCmd As SqlCeCommand = Nothing
Try
[ô]abrindo conexão com o banco de dados.
oConn.Open()
strSQL.Append(StrRelatorio)
[ô]definindo os parâmetros do SqlCommand
oCmd = New SqlCeCommand(strSQL.ToString, oConn)
oCmd.CommandType = CommandType.Text
[ô]oCmd.Parameters.Add(New _
[ô]SqlCeParameter([Ô]@CountryName[Ô], SqlDbType.NVarChar)).Value = strCountryName
[ô]carregando os dados do banco de dados
Dim oDataReader As SqlCeDataReader = _
oCmd.ExecuteReader(CommandBehavior.CloseConnection)
[ô]carregar o DataTable com base no DataReader
oTable.Load(oDataReader)
Catch ex As Exception
MsgBox(ex.Message)
Finally
[ô]liberando os objetos
oConn.Dispose()
oConn = Nothing
End Try
Return oTable
End Function