title: I'm having a problem connecting a database table to a report at run-time in Microsoft ReportViewer in VB.Net 2010
body: <p>I'm writing a production reporting app for a small manufacturing company.  Production data is added to an MSAccess database using the VB.Net interface and then the user can select a month and the monthly production is displayed using MS ReportViewer and a predesigned report stored in a file called Report1.rdlc.  Before the report is loaded, I create the report data in a temporary table in the database and the location of the database is fed to the report viewer at run-time.  The problem is that it works in the development environment, but not in the deployed executable.</p>
  
  <pre><code>Private Sub frmReport_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  
      ' Get the location of the data file from the configuration file
      Dim strConnectString As String
      strConnectString = ""
  
      FileOpen(1, "ProdPlan.cfg", OpenMode.Input)
      Input(1, strConnectString)
      FileClose(1)
      strConnectString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source= " &amp; strConnectString
  
      ' Add the local data file as the new data source for the report
      ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", strConnectString))
      Me.DataTable1BindingSource.DataSource = DataSet1
      Me.DataTable1TableAdapter.Connection.ConnectionString = strConnectString
      Me.DataTable1TableAdapter.Fill(Me.DataSet1.DataTable1)
      Me.DataTable1TableAdapter.GetData()
  
      ' Set the printing settings for the report
  
      Dim pageSettings = New Printing.PageSettings()
  
      pageSettings.PaperSize = New Printing.PaperSize("Custom", 850, 1100)
      pageSettings.Landscape = True
      pageSettings.Margins.Left = 75
      pageSettings.Margins.Right = 75
      pageSettings.Margins.Top = 75
      pageSettings.Margins.Bottom = 75
  
      Me.ReportViewer1.SetPageSettings(pageSettings)
  
      Me.ReportViewer1.RefreshReport()
  
  End Sub
  </code></pre>
  
  <p>When I first open the deployed program and run a report, it runs fine, but then when I add new data to the database, the report no longer runs.  The form comes up OK, but there is no data in the report.  When I check in the database, the data is there, and the temporary reporting table is filled correctly.  I suspect the problem is that the report viewer is somehow losing the connection to the database when new data is added, but I have no clue as to why that would happen in the run-time version and not the development version.  I'm connecting the database to the report every time I load the report form, as shown in the code segment.</p>