参数未传递到存储过程

编程入门 行业动态 更新时间:2024-10-11 13:23:44
本文介绍了参数未传递到存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个导出页面,我正在尝试使用该页面将动态创建的文件下载给用户.在主页中,我使用记录集来存储从SQL存储过程返回的数据,然后将内容转储到Grid中. 然后,我希望允许用户将网格内容另存为定界的文本文件选项卡.因此,我将它们重定向到另一页,并调用相同的SQL存储过程来填充记录集,并将其作为下载内容写入文件. 问题是参数(使用与另一页上完全相同的代码)没有传递给SQL,因此我的记录集返回为空.如果我将默认值放在SP中,则会返回记录集,并创建并下载文件.

I have an export page that I am trying to use to download a file created on the fly to the user. In the main page I use a record set to store data returned from a SQL Stored procedure and then dump the contents into a Grid. I then want to allow the user to save the grid contents as a text file tab delimited. So i redirect them to another page and call the same SQL stored procedure to populate the recordset and write it to a file as a download. The problem is the parameters (using the exact same code that works on the other page) are not being passed to SQL so my record set comes back empty. If I place default values in the SP the record set is returned and the file is created and downloaded.

set connUBC3=Server.CreateObject("ADODB.Connection") connUBC3.Open "UBC" If Err.number <> 0 then TrapError Err.source & ": " & Err.description End If set cmdTranByCardNo = Server.CreateObject("ADODB.Command") set cmdTranByCardNo.ActiveConnection = connUBC3 cmdTranByCardNo.CommandText = "Transaction_GetByMerchantIdAndCardNo" cmdTranByCardNo.CommandType = adCmdStoredProc cmdTranByCardNo.Parameters.Add("@MerchantID", SqlDbType.nvarchar) cmdTranByCardNo.Parameters("@MerchantID").Value = vMID cmdTranByCardNo.Parameters.Add("@CardNo", SqlDbType.nvarchar) cmdTranByCardNo.Parameters("@CardNo").Value = vCardNoString 'Process results set SearchTranByCardNoRS = cmdTranByCardNo.Execute ' @MerchantID = vmid,@CardNo = vcardnostring dim icount2 icount2 = SearchTranByCardNoRS.RecordCount If Err.number <> 0 then TrapError Err.source & ": " & Err.description End If SearchTranByCardNoRS.MoveFirst if not SearchTranByCardNoRS.eof then headertext = "attachment;filename=GiftTransByDate-" & vMID & fileExt Response.AddHeader "Content-Disposition",headertext Response.Write "TRANS DATE" & sCh & "TERMINAL NUMBER" & sCh & "LOCATION NAME" & sCh & "CARD NUMBER" & sCh & "TRANS TYPE" & sCh & "TRANS AMOUNT" & sCh & "REMAINING BALANCE" & sCh & "AUTHORIZATION" & vbCrLf SearchTranByDateRS.MoveFirst do until SearchTranByCardNoRS.eof Response.Write SearchTranByCardNoRS("TranDate") & sCh & SearchTranByCardNoRS("TerminalID") & sCh & SearchTranByCardNoRS("LocationName") & sCh & SearchTranByCardNoRS("CardNumber") & sCh & SearchTranByCardNoRS("TranType") & sCh & SearchTranByCardNoRS("TranAmount") & sCh & SearchTranByCardNoRS("RemainingBal") & sCh & SearchTranByCardNoRS("AuthCode") & vbCrLf SearchTranByCardNoRS.Movenext Loop SearchTranByCardNoRS.close SearchTranByCardNoRS = nothing End if

那么,为什么完全相同的查找在一页而不是另一页上起作用? 我在多个存储过程中都遇到相同的问题,它们都在一页上工作,但不在一页上? 感谢

So why does the exact same lookup work in one page and not the other? I have the same problem with multiple Stored Procedures where they all work on one page but not this one? Thanks

推荐答案

未提供与此页面关联的HTML,但可能缺少或未正确设置vMID和vCardNoString的值.我认为您需要先检查这些. 祝您好运! The HTML associated with this page aren''t given, but the values of vMID and vCardNoString that are probably missing or not set properly. I think you need to check these first. Good luck!

此页面上没有HTML,它是从原始页面像这样被调用的 There is no HTML on this page it is called from the original page like this <tr> <td width="100%" class="caps" align="left" colspan="9"> <img border="0" src="images/notepad-icon.jpg" align="absmiddle" width="30" height="30">Export To File <a href="GiftCard-Export.asp?<%=Request.Querystring%>MID=<%=MIDCode %>&StartDateGC=<%=Date1 %>&EndDateGC=<%=Date2 %>&mode=GiftTransByDate&ExportStyle=tdf" target="_blank">[Tab Delimited] </a> OR <a href="GiftCards.asp?<%=Request.Querystring%>MID=<%=MIDCode %>&Date1=<%=vDate1 %>&Date2=<%=vDate2 %>&mode=GiftTransByDate& ExportStyle=csv">[Comma Delimited]</a></img> <a href="GiftCards.asp?<%=Request.Querystring%>&MID=<%=MIDCode %>&StartDateGC=<%=Date1 %>&EndDateGC=<%=Date2 %>&mode=GiftTransByDate&ExportStyle=excel"><img border="0" src="images/excel_icon.gif" align="absmiddle">Export to Excel</img></a> </td> </tr>

导出页面没有adovb包含文件 谢谢您的宝贵时间 The export page did not have the adovb include file Thanks for your time

更多推荐

参数未传递到存储过程

本文发布于:2023-10-12 04:31:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483724.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:存储过程   参数

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!