Hi all,
First post here, not sure if this post belongs here but here I go.
I am working with vb.net 2010 SQL express 2008 and ReportViewer. I have created a form that a user can add, edit and delete data which is all stored in an SQL db. I am printing out reports for the user with ReportViewer. The issue I am encountering now is that at runtime if I make any changes and decided to view the changes via a report with ReportViewer, the change will not reflect. I have to close the program and open it up again so that I can view the changes. What do I have to do in order to view the changes view ReportViewer during runtime? This is my code:
First Form, Process Button:
[XCODE]
At this point, once the data is processed, the data is saved into the DB.
I hit the back button to go to the main menu and choose the from that carries the Reportviewer.
Form with Report Viewer code:
to view the report I click on the print button.
[XCODE]
At this point after processing the data, the ReportViewer will not show the updated information. I have to close the program and open the program again, go to Report Viewer and view what I have previously processed.
What do I have to do so the ReportViewer can show the updated data during runtime?
Please help!
Thanks,
Larry
First post here, not sure if this post belongs here but here I go.
I am working with vb.net 2010 SQL express 2008 and ReportViewer. I have created a form that a user can add, edit and delete data which is all stored in an SQL db. I am printing out reports for the user with ReportViewer. The issue I am encountering now is that at runtime if I make any changes and decided to view the changes via a report with ReportViewer, the change will not reflect. I have to close the program and open it up again so that I can view the changes. What do I have to do in order to view the changes view ReportViewer during runtime? This is my code:
First Form, Process Button:
[XCODE]
[LIST=1] Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcess.Click ' Declare the values Dim dblHrsWorked As Double Dim dblHrRate As Double Dim dblTotalMedSS As Double Dim dblTotalGrs As Double Dim dblTotalBfWH As Double Dim dblWithHold As Double Dim dblLessWH As Double Dim dblGndTotal As Double Dim dblMedSS As Double = 0.0565 ' validates that user entered a value for hours worked If txtHrsWrkd.Text = "" Then MessageBox.Show("Please do not leave hours worked blank.", "Error", MessageBoxButtons.OK) txtHrsWrkd.Focus() txtMedSS.Clear() Exit Sub End If ' assign user input to variables dblHrsWorked = Convert.ToDouble(txtHrsWrkd.Text) dblHrRate = txtHrRate.Text dblWithHold = lblWithH.Text ' EMPLOYEE'S ALLOWANCE OF WITHHOLDINGS ' checks to see the employee's filing status Dim IsMarried As Boolean If lblfStatus.Text = "SINGLE" Then ' if Single IsMarried = False ElseIf lblfStatus.Text = "MARRIED" Then ' if Married IsMarried = True ElseIf lblfStatus.Text = "HEAD OF HOUSEHOLD" Then ' if Head of Houshold IsMarried = False ElseIf lblfStatus.Text = "WIDOWER" Then MessageBox.Show("Please select a different filing status" & _ " other than " & lblfStatus.Text & " !") txtHrsWrkd.Focus() txtHrsWrkd.Clear() Exit Sub End If ' calculate total dblTotalGrs = (dblHrRate * dblHrsWorked) dblTotalMedSS = dblTotalGrs * dblMedSS dblTotalBfWH = dblTotalGrs - dblTotalMedSS ' the value of federal tax withholding dblLessWH = CalcBiWeeklyFedWHFromTableB1(dblTotalGrs, IsMarried, dblWithHold) ' Grand Total earned dblGndTotal = dblTotalGrs.ToString - dblLessWH.ToString - dblTotalMedSS ' output total with currency format txtGross.Text = Format(dblTotalGrs, "Currency") txtMedSS.Text = Format(dblTotalMedSS, "Currency") 'txtTotalbfwh.Text = Format(dblTotalBfWH, "Currency") txtWithHValue.Text = Format(dblLessWH, "Currency") txtGndTotal.Text = Format(dblGndTotal, "Currency") Try ' To check if the employee is already in our database Dim conn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Larry\Documents\Visual Studio 2010\Projects\" & _ "DDSPayRoll\DDSPayRoll\DDSPayRoll.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True") Dim cmds As New SqlCommand("SELECT * FROM fedtax WHERE eid = '" & txtEmpID.Text & "' AND payfrom = '" & CDate(dtpFromDate.Text) & "' " & _ "AND payto = '" & CDate(dtpToDate.Text) & "' ", conn) conn.Open() Dim sdr As SqlDataReader = cmds.ExecuteReader() If (sdr.Read() = True) Then txtHrsWrkd.Clear() txtMedSS.Clear() txtGross.Clear() 'txtTotalbfwh.Clear() txtWithHValue.Clear() txtGndTotal.Clear() txtHrsWrkd.Focus() MessageBox.Show("User already has payroll for the specified pay period!") Exit Sub Else Dim con As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Larry\Documents\Visual Studio 2010\Projects\" & _ "DDSPayRoll\DDSPayRoll\DDSPayRoll.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True") Dim constr As String = (" INSERT INTO fedtax " & _ "(eid, payfrom," & _ " payto, hrswrkd, hrlyrate, " & _ "grosstotal, medss, withholding, " & _ " grandtotal)" & _ " values " & _ " ( @val1, @val2, @Val3," & _ " @Val4, @Val5, @Val6, @Val7," & _ " @Val9, @Val10) ") ' totalbfwh, ' @Val8, Dim cmd As New SqlCommand(constr, con) 'Dim kk = cmd.BeginExecuteNonQuery() cmd.Parameters.Add(New SqlParameter("@val1", txtEmpID.Text)) cmd.Parameters.Add(New SqlParameter("@val2", (Format(dtpFromDate.Text, "short date")))) cmd.Parameters.Add(New SqlParameter("@val3", (Format(dtpToDate.Text, "short date")))) cmd.Parameters.Add(New SqlParameter("@val4", txtHrsWrkd.Text)) cmd.Parameters.Add(New SqlParameter("@val5", txtHrRate.Text)) cmd.Parameters.Add(New SqlParameter("@val6", txtGross.Text)) cmd.Parameters.Add(New SqlParameter("@val7", txtMedSS.Text)) 'cmd.Parameters.Add(New SqlParameter("@val8", txtTotalbfwh.Text)) cmd.Parameters.Add(New SqlParameter("@val9", txtWithHValue.Text)) cmd.Parameters.Add(New SqlParameter("@val10", txtGndTotal.Text)) con.Open() Dim i As Integer i = cmd.ExecuteNonQuery() If i > 0 Then ' cmd.EndExecuteNonQuery(kk) MessageBox.Show("Payroll information Saved!") txtHrsWrkd.Clear() txtMedSS.Clear() txtGross.Clear() 'txtTotalbfwh.Clear() txtWithHValue.Clear() txtGndTotal.Clear() txtHrsWrkd.Focus() Else MessageBox.Show("Payroll information failed to save") End If con.Close() con = Nothing End If Catch ex As Exception MessageBox.Show("Please fill in all the information. ", "Error") End Try [*] End Sub [/LIST][/XCODE]
At this point, once the data is processed, the data is saved into the DB.
I hit the back button to go to the main menu and choose the from that carries the Reportviewer.
Form with Report Viewer code:
to view the report I click on the print button.
[XCODE]
[LIST=1]Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click If cboPayPeriod.SelectedItem = Nothing Then MessageBox.Show("Please select a Pay Period. ", "Error") Exit Sub End If Dim biwk As New Report_BWk Dim value As New Date lblPayFrom.Text = cboPayPeriod.Text ' SelectedItem ' MessageBox.Show(lblPayFrom.Text) value = lblPayFrom.Text biwk.valpay = value Me.biweeklyTableAdapter.Fill(Me.DDSPayRollDataSet.biweekly, biwk.valpay) Me.ReportViewerbiwk.RefreshReport() Me.ReportViewerbiwk.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout) [*] End Sub [/LIST][/XCODE]
At this point after processing the data, the ReportViewer will not show the updated information. I have to close the program and open the program again, go to Report Viewer and view what I have previously processed.
What do I have to do so the ReportViewer can show the updated data during runtime?
Please help!
Thanks,
Larry