UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> How To Revise Exising Sp To Handle Parameter Passed From Ashx To Sp ?    
 
   
smyeong
post Feb 8 2018, 09:49 PM
Post#1



Posts: 394
Joined: 6-November 02
From: Malaysia


Hi, there. I have created a new sp in SQL but it failed to show specific records which are based on the parameters captured in ashx page from ASP page. See attached photo how I pass 3 parameters from asp to ashx then call SP...

---------------------- $_rpt_vehicle --------------------------------

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

AS SET NOCOUNT ON


BEGIN

SELECT mt.*
FROM VW_RPT_van2 mt
where
cardno = @Card
and
trdate between @txtLog_Date and @txtCompleted_Date
Order by TRDATE
-------------------------------- end -----------------------------------

------------------------- rpt_vehicle.ashx --------------------------------
<%@ WebHandler Language="VB" Class="rpt_vehicle" %>

Imports Microsoft.Reporting.WebForms

Public Class rpt_vehicle : 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 = "[$_Rpt_Vehicle]"
dComm.CommandType = CommandType.StoredProcedure
dComm.Parameters.Add(New SqlParameter("@Card", CardNo(Page)))
dComm.Parameters.Add(New SqlParameter("@txtLog_Date", txtLog_Date(Page)))
dComm.Parameters.Add(New SqlParameter("@txtCompleted_Date", txtCompleted_Date(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_vehicle.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 txtLog_Date(Page As HttpContext) As DateTime
Get
Dim iData As DateTime

If Not DateTime.TryParse(Page.Request.QueryString("txtLog_Date"), iData) Then iData = DateTime.Now

Return iData
End Get
End Property

Public ReadOnly Property txtCompleted_Date(Page As HttpContext) As DateTime
Get
Dim iData As DateTime

If Not DateTime.TryParse(Page.Request.QueryString("txtCompleted_Date"), iData) Then iData = DateTime.Now

Return iData
End Get
End Property

End Class

----------------------------------- end ----------------------------------------------------

my asp goes like this
<<Removed Link to external website per our guidelines>>
Pls advise how I can revise my sp so that I can show all the records based on above parameter passing..?
FYI, the SQL view VW_RPT_van2 written in sp is well tested and able to show all required records.

Thanks
This post has been edited by GroverParkGeorge: Feb 9 2018, 07:43 AM
Reason for edit: Please refresh your reading of the forum Guidelines

Attached File(s)
Attached File  ashx_sp.png ( 109.42K )Number of downloads: 2
 

--------------------
We should see thing in both side. positive and negative
Pls visit http://ipohtech.blogspot.com for tech solutions around the world..
Malaysia.
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    20th February 2018 - 06:43 PM