Here is a cut down version of the code.
There are two global variables:
'MyReport' which is the name of the rdlc file,
and 'query' which is the SELECT statement used.
When you run it it is OK the first few times then the top of the report is missing.
Code:Option Strict Off Option Explicit On Imports System.Windows.Forms Imports System.Data.SqlClient Public Class frmReport Private Sub frmReport_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Dim AppPath As String AppPath = Environment.CurrentDirectory() ReportViewer1.Reset() ' this is important ReportViewer1.LocalReport.DisplayName = MyReport ReportViewer1.LocalReport.ReportEmbeddedResource = "MIS." & MyReport & ".rdlc" ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local ReportViewer1.LocalReport.ReportPath = AppPath & "\" & MyReport & ".rdlc" ReportViewer1.LocalReport.SetParameters(New Microsoft.Reporting.WinForms.ReportParameter("MyParam1", MyParameters(0))) Me.Size = New Size(1030, 600) ' A4 landscape ReportQuery = query ' create a data adaptor Dim da As SqlDataAdapter = New SqlDataAdapter(ReportQuery, SQLConnection) ' create a new data set Dim ds As DataSet = New DataSet ' fill the data adapter da.Fill(ds) ' clear the datasource ReportViewer1.LocalReport.DataSources.Clear() ' set the dataource (DataSet1 is defined in the matrix in the rdlc file) Dim rds1 As New Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", ds.Tables(0)) ' add a new datasource ReportViewer1.LocalReport.DataSources.Add(rds1) ReportViewer1.RefreshReport() End Sub End Class




Reply With Quote