繁体   English   中英

在VB.NET中调用自定义SQL Server存储过程和URL重定向

[英]Calling custom SQL Server stored procedure and URL redirect in VB.NET

我正在构建一个aspx Web应用程序。 我的应用程序中有一个“提交”按钮,用于调用自定义存储过程。 一旦存储过程执行完毕,我试图找出用于重定向用户的代码。

这是按钮+存储过程的VB.NET代码:

Public Overrides Sub SubmitRequisition1_Click(ByVal sender As Object, ByVal args As EventArgs)
  Try
    Dim CatalogID as Integer
    CatalogID = Ctype(me.CatalogID.text, int32)

    DbUtils.StartTransaction() 
    Dim spName As BaseClasses.Data.StoredProcedure = Nothing

    Dim firstParameter as BaseClasses.Data.StoredProcedureParameter = Nothing
    firstParameter = New BaseClasses.Data.StoredProcedureParameter("@p_CatalogID", CatalogID, System.Data.SqlDbType.Int, System.Data.ParameterDirection.Input)

    Dim parameterList(0) As BaseClasses.Data.StoredProcedureParameter

    parameterList(0) = firstParameter

    spName = New StoredProcedure("DatabaseStoktrak1", "dbo.pHSEProcessWardReqsParams", parameterList) 

    spName.RunNonQuery()

    DbUtils.CommitTransaction() 
Catch ex As Exception
   ' Report the error message to the end user'
    BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
    DbUtils.RollBackTransaction()
Finally
    DbUtils.EndTransaction() 
End Try    
End Sub

当我插入这行代码时

Response.Redirect("../LocationCatalog/WARDEditLocationCatalog.aspx")

我收到编译器错误

编译器错误消息:BC30451:未声明名称“ Response”。

这行代码是否正确?如果正确,则需要去哪儿? 我需要声明什么吗?

任何帮助是极大的赞赏。

问候,托马斯

出于兴趣,确实使用HttpContext.Current.Response.Redirect("../LocationCatalog/WARDEditLocationCatalog.aspx")代替。

我在以前的ASP Web应用程序中遇到了这个问题,并对此进行了修复。

编辑

如果不是这样,我认为您可能需要在VB代码页的顶部声明它。

Imports System.Web

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM