主题:  回复页出错

hcj52

职务:普通成员
等级:1
金币:0.0
发贴:6
#12006/7/4 9:02:18
我的留言板在本机测试没问题上传后回复页就出错了,出错提示是,操作必须使用一个可更新的查询,出错代码是: MM_editCmd.Execute

我是用Dreamweaver做的,数据是Access的.下面是我事个回复页的全代码,希望能得到好心人的帮助,帮我看看下面的代码中到底哪里出问题了.谢谢
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/hcj52.asp" -->
<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME")
If (Request.QueryString <> "" Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables

If (CStr(Request("MM_update") = "form1" And CStr(Request("MM_recordId") <> "" Then

MM_editConnection = MM_hcj52_STRING
MM_editTable = "main"
MM_editColumn = "id"
MM_recordId = "" + Request.Form("MM_recordId" + ""
MM_editRedirectUrl = "guanni.asp"
MM_fieldsStr = "name|value|Email|value|Ctent|value|Rply|value"
MM_columnsStr = "name|',none,''|Email|',none,''|Ctent|',none,''|Rply|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "" Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "" Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If

End If
%>
<%
' *** Update Record: construct a sql update statement and execute it

If (CStr(Request("MM_update") <> "" And CStr(Request("MM_recordId") <> "" Then

' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),","
MM_delim = MM_typeArray(0)
If (MM_delim = "none" Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none" Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none" Then MM_emptyVal = ""
If (MM_formVal = "" Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "" Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'" Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''" & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId

If (Not MM_abortEdit) Then
' execute the update
Set MM_editCmd = Server.CreateObject("ADODB.Command"
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl <> "" Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("id" <> "" Then
Recordset1__MMColParam = Request.QueryString("id"
End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset"
Recordset1.ActiveConnection = MM_hcj52_STRING
Recordset1.Source = "SELECT * FROM main WHERE id = " + Replace(Recordset1__MMColParam, "'", "''" + ""
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()

Recordset1_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
.STYLE1 {
    font-size: 14px;
    font-weight: bold;
}
-->
</style></head>

<body>
<table width="600" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FF6600">
<tr>
<td height="30" align="center"><span class="STYLE1">管理员回复</span></td>
</tr>
<tr>
<td><form ACTION="<%=MM_editAction%>" METHOD="POST" id="form1" name="form1">
<label>姓名:
<input name="name" type="text" id="name" value="<%=(Recordset1.Fields.Item("name".value)%>" />
</label>
<p>
<label>
信箱:
<input name="Email" type="text" id="Email" value="<%=(Recordset1.Fields.Item("Email".value)%>" />
</label>
</p>
<p>
<label>
留言:
<textarea name="Ctent" cols="70" rows="5" id="Ctent"><%=(Recordset1.Fields.Item("Ctent".value)%></textarea>
</label>
</p>
<p>
<label>
回复:
<textarea name="Rply" cols="70" rows="5" id="Rply"><%=(Recordset1.Fields.Item("Rply".value)%></textarea>
</label>
</p>
<p>
<label>
<input type="submit" name="Submit" value="回复" />
</label>
<label>
<input type="reset" name="Submit2" value="重置" />
</label>
</p>




<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%= Recordset1.Fields.Item("id".value %>">
</form> </td>
</tr>
</table>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>



三仙半

职务:普通成员
等级:1
金币:0.0
发贴:241
#22006/7/4 17:56:16
建议学习一下ADO的相关内容,然后抛弃DW的数据连接功能,因为牵涉到数据源的问题,这种做法除非服务器是你自己的,否则很容易出错的。


闭起眼睛看人生