Last post Jun 03, 2020 07:59 PM by mgebhard
Jun 03, 2020 05:14 PM|rkrex|LINK
I am working on opening a rdlc in reportviewer from another form using vb.net webforms using a stored procedure that takes three parameters. I have included the code as far as my issue is concerned where I was wondering is there something I need to include
to stop the code that opens the reportviewer from once it reaches the end of the procedure in the form load event calling the load event again. I don't understand why it's doing this. Thanks Guys I really need your help with this one. Thank You !!!
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim endddate As String = Now.ToString("MM/dd/yyyy")
If Request.QueryString("enddate") IsNot Nothing OrElse IsDate(Request.QueryString("endddate")) Then
endddate = Request.QueryString("enddate")
Dim startdate As String = CDate(endddate).AddDays(-1)
If Request.QueryString("startdate") IsNot Nothing OrElse IsDate(Request.QueryString("startdate")) Then
startdate = Request.QueryString("startdate")
If (DateDiff(DateInterval.Day, CDate(startdate), CDate(endddate))) < 0 Then
startdate = CDate(endddate).AddDays(-1)
If (DateDiff(DateInterval.Year, CDate(startdate), CDate(endddate))) > 5 Then
startdate = CDate(endddate).AddYears(-5)
Dim EmailFlag = CType(Request.QueryString("EmailFlag"), EmailBatchFlag)
Dim EmailFlagDdl As String
Dim EmailFlagTxt As String
If (Request.QueryString("EmailFlag") IsNot Nothing) Then
EmailFlagDdl = IIf(EmailFlag = 1, "X", "A")
EmailFlagTxt = IIf(EmailFlag = 1, "Delinquent", "Accessed")
EmailFlagDdl = "X"
EmailFlagTxt = "Delinquent"
Dim dt As DataTable = GetSPResult()
ReportViewer1.Visible = True
ReportViewer1.LocalReport.ReportPath = "Report.rdlc"
Dim rds = New ReportDataSource("DataSet1", dt)
Public Function GetSPResult() As DataTable
Dim ResultsTable As DataTable = New DataTable()
Dim conn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("EzTaxExpressConnectionString").ConnectionString)
Dim cmd As SqlCommand = New SqlCommand("[oesc_BusinessInformation].[getSentEmail]", conn)
cmd.CommandType = CommandType.StoredProcedure
Dim adapter As SqlDataAdapter = New SqlDataAdapter(cmd)
Catch ex As Exception
If conn IsNot Nothing Then
Jun 03, 2020 06:25 PM|mgebhard|LINK
There is nothing in the posted code that would cause the page to load multiple times. The issue must be in the code that calls this page.
Also, the code shown has questionable logic. The page_Load validates querystring values but the GetSpResults ignore the validation and grabs the querystring values directly.
Form the looks of your code and the problem statement, I think you need to spend more time debugging your code.
Jun 03, 2020 07:37 PM|rkrex|LINK
Thanks for your help !!! I have attached the code from the form that calls the above code in the form thats loading and will subsequently display the report. Maybe using "response.redirect" is the problem. And to respond to one of your comments. Yes I did
hard code one of the parameters because I need to get some more clarity....I didnt write that code so I need a better understanding of the use case. But again Thanks for your help and please see the attached code.
Private Sub SearchButton_Click(sender As Object, e As EventArgs) Handles SearchButton.Click
Response.Redirect("Viewer.aspx?startdate=" + StartDateTxt.Text + "&enddate=" + EndDateTxt.Text + "&EmailFlag=" + EmailFlagDdl.SelectedValue)
Jun 03, 2020 07:59 PM|mgebhard|LINK
I still do not see any code that would cause multiple HTTP request to Viewer.aspx.