Good day, I have a ReportViewer showing a report that is bound to a dataset. The dataset gets its data from a Access database backend. I have a separate form that allows the user to add/update/delete data. My problem is when the user makes changes to the data using the data entry form, the report does not reflect those changes. I have to close the entire program and reopen it before the changes take effect on my report. Can somebody help?

Me.transactionsTableAdapter.Fill(Me.transactions._transactions)  
Me.ReportViewer1.RefreshReport()

I've been doing some readings online, and it seems that I need some code that rebinds data to the reportviewer at runtime, but so far I have not been able to solve this. Can anyone help me out?

Thanks so much.

Hi, thanks for replying.

That article only tells me how to rebind a datasource in design view, whereas I need the rebinding to occur at runtime.

Right now, I have the following code in the Form_Load event on the form that houses my ReportViewer:

Me.ReportViewer1.Reset()        
Me.ReportViewer1.ProcessingMode = ProcessingMode.Local
Me.ReportViewer1.LocalReport.ReportPath = "GL.rdlc"
Dim dt As DataTable = Me.transactions.Tables(0)
Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("GL", dt))
Me.transactionsTableAdapter.Fill(Me.transactions._transactions)
Me.ReportViewer1.RefreshReport()

That code should essentially be a rebinding, yet the report is still not being updated after the data in the backend has been modified.

How do you update your record? Not sure about your code but method xxxxBindingSource.EndEdit() must be called before before xxxxtTableAdapter.Update(..). Please show us the code you were updating datasource. (You can attach your project here)

Hi,

Here's the code in the data entry form that updates the data within the database

Dim sql As String
Dim conn As New OleDb.OleDbConnection
Dim ds As New DataSet

Conn.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =  C:\Backend.mdb"
conn.Open()

sql = "UPDATE [TRANSACTIONS] SET [AMOUNT] = Amount.Text WHERE [TRANSACTION_NUMBER] = '" & currentid & "'"
da = New OleDb.OleDbDataAdapter(sql, conn)          
da.Fill(ds, "update record")

conn.Close()

..and here is the code in the form that contains the ReportViewer.

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

'TODO: This line of code loads data into the 'transactions.transactions' table. You can move, or remove it, as needed
        Me.transactionsTableAdapter.Fill(Me.transactions._transactions)
        Me.ReportViewer1.RefreshReport()
End Sub

The data entry form executes an SQL UPDATE statement and directly updates the data on the backend database (Access 2007 MDB file). The ReportViewer is from another form, but it should be reading from the same table in the backend.

My problem is that when I update the database using the data entry form, the ReportViewer doesn't update to reflect the changes that I had just made.

Here's the code in the data entry form that updates the data within the database

Dim sql As String
Dim conn As New OleDb.OleDbConnection
Dim ds As New DataSet

Conn.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =  C:\Backend.mdb"
conn.Open()

sql = "UPDATE [TRANSACTIONS] SET [AMOUNT] = Amount.Text WHERE [TRANSACTION_NUMBER] = '" & currentid & "'"
da = New OleDb.OleDbDataAdapter(sql, conn)          
da.Fill(ds, "update record")

conn.Close()

This code will not update your database.

?? Really? I am pretty sure the SQL is running properly and is making changes to the table within the Access database at runtime, because I refresh the data entry form after each update, and the updated content shows up.

Am I missing something?

hey blades I have the same issue as you, the only difference is that i am using SQL. Did you ever get this issue resloved?

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.