Dreamweaver ASP更新记录未传递查询字符串

时间:2015-02-12 11:37:24

标签: vbscript asp-classic dreamweaver

我正在尝试使用Dreamweaver更新SQL数据库中的记录,该记录可以自行运行,但我希望goto url显示更新的产品记录。

我试图通过一些在线教程来解决这个问题,但不断出现这个错误

Microsoft VBScript runtime error '800a01a8'

Object required: ''

/coding_requests/dashboard.asp, line 33

这是我的代码;

<%
If (CStr(Request("MM_update")) = "coding_technical_code") Then
  If (Not MM_abortEdit) Then
    ' execute the update
    Dim MM_editCmd

    Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_conn_PSCRM_Demo_STRING
    MM_editCmd.CommandText = "UPDATE DBA.coding_requests SET prodref = ?, lastupdatedby = ?, coding_status = ? WHERE prodref = ?" 
    MM_editCmd.Prepared = true
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 201, 1, 25, Request.Form("prodref")) ' adLongVarChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 201, 1, 3, Request.Form("lastupdatedby")) ' adLongVarChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 201, 1, 6, Request.Form("coding_status")) ' adLongVarChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 200, 1, 25, Request.Form("MM_recordId")) ' adVarChar
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    ' append the query string to the redirect URL
    Dim MM_editRedirectUrl
    MM_editRedirectUrl = "coding.asp?prodref=" & (RS_Dashboard_Coding_TechnicalView.Fields.Item("prodref").Value)
    If (Request.QueryString <> "") Then
      If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
        MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
      Else
        MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
      End If
    End If
    Response.Redirect(MM_editRedirectUrl)
  End If
End If
%>

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

此错误的原因很简单,第33行包含一个Object Reference (使用Set variablename =创建的变量),但运行时无法将其识别为对象引用已创建(实例化)。

评论中解释的第33行指出

MM_editRedirectUrl = "coding.asp?prodref=" & (RS_Dashboard_Coding_TechnicalView.Fields.Item("prodref").Value)

此行上的对象引用为RS_Dashboard_Coding_TechnicalView,但在提供的代码中没有使用

实例化的对象引用RS_Dashboard_Coding_TechnicalView的位置
Set RS_Dashboard_Coding_TechnicalView = Server.CreateObject("ADODB.Recordset")

以上一行是基于对象参考名称和您尝试使用的方法(.Fields.Item())的有根据的猜测。


如果您只是尝试将prodref的值从表单POST传递到MM_editRedirectUrl变量,@SearchAndResQ建议here只传递{{1}的值你必须把它放在那条线上;

Request.Form("prodref")