×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How To Re-code Ashx For Correct Parameter, asp.net

How To Re-code Ashx For Correct Parameter, asp.net

How To Re-code Ashx For Correct Parameter, asp.net

(OP)
How To Re-code Ashx For Correct Parameter, asp.net

02-02-2018 04:28 PM|LINK


http://xx/rpt_vehicle.ashx?cardno=0000055799&t...='2/2/2018'&txtCompleted_Date='2/3/2018'

Hi, all.
Attached is showing how the 3 parameters are passed to ahsx asp.net. But in the ashx, it would use something like as below :

--- http://xx/rpt_Detail_dept.ashx?cardno=0000008904&a... -----

This is to select all the record based on month.
Now my requirement is to change to cardno=0000055799&txtLog_Date='2/2/2018'&txtCompleted_Date='2/3/2018'

can somebody help to revise below ashx coding so that it can pass correct parameter to my store procedure in MSsql..

<%@ WebHandler Language="VB" Class="rpt_Detail_Dept" %>

Imports Microsoft.Reporting.WebForms

Public Class rpt_Detail_Dept : Implements IHttpHandler, IRequiresSessionState
Private dConn As New SqlConnection(ConfigurationManager.ConnectionStrings("DataDB").ConnectionString)

Public Sub ProcessRequest(Page As HttpContext) Implements IHttpHandler.ProcessRequest
Try
Dim dComm As New SqlCommand("", dConn), tData As New DataTable()

dComm.CommandText = "[$_RptDetail]"
dComm.CommandType = CommandType.StoredProcedure
dComm.Parameters.Add(New SqlParameter("@Card", CardNo(Page)))
dComm.Parameters.Add(New SqlParameter("@Mnth", Month(Page)))
dComm.Parameters.Add(New SqlParameter("@Year", Year(Page)))
dComm.CommandTimeout = 0

Dim dData As New SqlDataAdapter(dComm) : dData.Fill(tData) : dData.Dispose() : dComm.Dispose()
Dim iStrm As String() = Nothing, iWarn As Warning() = Nothing, iEncd As String = "", iExtn As String = "", iMime As String = ""
Dim iRepo As New LocalReport(), iData As New ReportDataSource()

iData.Name = "tMain" : iData.Value = tData
iRepo.ReportPath = Page.Server.MapPath("~/rpt_Detail_Dept.rdlc")
iRepo.DataSources.Add(iData)

Dim iByte As Byte() = iRepo.Render("PDF", Nothing, iMime, iEncd, iExtn, iStrm, iWarn)

Page.Response.Buffer = True
Page.Response.Clear() : Page.Response.ContentType = iMime
Page.Response.AppendHeader("content-disposition", "attachment; filename=" & Now.ToString("yyyyMMdd_HHmmss") & "." & iExtn)
Page.Response.OutputStream.Write(iByte, 0, iByte.Length)
Page.Response.Flush()
Catch ex As Exception
Page.Response.ContentType = "text/html" : Throw ex
Finally
If Not dConn.State = ConnectionState.Closed Then dConn.Close()
End Try
End Sub

Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property

Public ReadOnly Property CardNo(Page As HttpContext) As String
Get
Dim iData As String

If Not String.IsNullOrWhiteSpace(Page.Request.QueryString("cardno")) Then
iData = Page.Request.QueryString("cardno")
Else
iData = ""
End If

Return iData
End Get
End Property

Public ReadOnly Property Month(Page As HttpContext) As Int32
Get
Dim iData As Int32

If Not Double.TryParse(Page.Request.QueryString("month"), iData) Then iData = Now.Month

Return iData
End Get
End Property

Public ReadOnly Property Year(Page As HttpContext) As Int32
Get
Dim iData As Int32

If Not Double.TryParse(Page.Request.QueryString("year"), iData) Then iData = Now.Year

Return iData
End Get
End Property

End Class

--------------------------- end of ashx ------------------------------------------------------------


Above ashx will pass the parameter to sp as below :

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROC [dbo].[$_Rpt_vehicle]
@Card VARCHAR(16),
@txtLog_Date Datetime,
@txtCompleted_Date Datetime

AS SET NOCOUNT ON


BEGIN
set @card = @card

SELECT cardno, trdate
FROM VW_RPT_van2
where
cardno = @Card
and
trdate between @txtLog_Date and @txtCompleted_Date

END
----------------------------- end of sp --------------------------


FYI, my sp is able to display all those record which are based on cardno and txtlog_date and txtCompleted_date
how can I modify the ashx so that I can display record on my asp page?

TQ

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close