MM_editCmd.Execute 出錯

lkc1620 2008-11-30 09:57:31
我是新手 完全跟隨書本做的加入會員系統 卻總是出錯

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/connMember.asp" -->
<%
Dim MM_editAction
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
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
If condition = "" Then
MM_IIf = ifFalse
Else
MM_IIf = ifTrue
End If
End Function
%>
<%
If (CStr(Request("MM_insert")) = "form1") Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd

Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_connMember_STRING
MM_editCmd.CommandText = "INSERT INTO memberdata (m_id, m_pw, m_name, m_class, m_classno, m_sex, m_birthday, m_phone, m_parphone, m_level) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 8, Request.Form("m_id")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 50, Request.Form("m_pw")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 50, Request.Form("m_name")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 2, Request.Form("m_class")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 2, Request.Form("m_classno")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 202, 1, 1, Request.Form("m_sex")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 135, 1, -1, MM_IIF(Request.Form("m_birthday"), Request.Form("m_birthday"), null)) ' adDBTimeStamp
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 202, 1, 8, Request.Form("m_phone")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param9", 202, 1, 8, Request.Form("m_parphone")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param10", 202, 1, 1, Request.Form("m_level")) ' adVarWChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "memberaddsuccess.asp"
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
%><!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=utf-8" />
<title>無標題文件</title>
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
left:86px;
top:43px;
width:423px;
height:418px;
z-index:1;
}
.style13 {font-family: Arial, Helvetica, sans-serif}
.style15 {font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #FFFFFF; font-size: 14px; }
.style17 {font-family: Arial, Helvetica, sans-serif; font-size: 14px; }
#apDiv2 {
position:absolute;
left:102px;
top:11px;
width:565px;
height:0px;
z-index:1;
}
-->
</style>
</head>

<body>
<div id="apDiv2">
<form id="form1" name="form1" method="POST" action="<%=MM_editAction%>">
<table width="395" height="357" border="1" cellspacing="0" bordercolor="#BFCCFF">
<tr>
<td width="171" height="23" bgcolor="#000066"><span class="style15"> User ID:</span></td>
<td width="214"><span class="style17">
<label>
<input name="m_id" type="text" id="m_id" />
*<br />
Student card number</label>
</span></td>
</tr>
<tr>
<td bgcolor="#000066"><span class="style15">Password:</span></td>
<td><span class="style17">
<label>
<input type="text" name="m_pw" id="m_pw" />
*<br />
Student's ID number</label>
</span></td>
</tr>
<tr>
<td bgcolor="#000066"><span class="style15">Name:</span></td>
<td><span class="style17">
<label>
<input type="text" name="m_name" id="m_name" />
*</label>
</span></td>
</tr>
<tr>
<td bgcolor="#000066"><span class="style15">Class:</span></td>
<td><span class="style17">
<label>
<input type="text" name="m_class" id="m_class" />
*</label>
</span></td>
</tr>
<tr>
<td bgcolor="#000066"><span class="style15">Class number:</span></td>
<td><span class="style17">
<label>
<input type="text" name="m_classno" id="m_classno" />
*</label>
</span></td>
</tr>
<tr>
<td bgcolor="#000066"><span class="style15">Gender:</span></td>
<td><span class="style17">
<label>
<input <%If (CStr("F") = CStr("m_sex")) Then Response.Write("checked=""checked""") : Response.Write("")%> type="radio" name="m_sex" id="m_sex" value="F" />
F
<input type="radio" name="m_sex" id="m_sex2" value="M" />
M*</label>
</span></td>
</tr>
<tr>
<td bgcolor="#000066"><span class="style15">Birthday</span></td>
<td><span class="style17">
<label>
<input type="text" name="m_birthday" id="m_birthday" />
* <br />
yyyy/mm/dd</label>
</span></td>
</tr>
<tr>
<td bgcolor="#000066"><span class="style15">Phone number:</span></td>
<td><span class="style17">
<label>
<input type="text" name="m_phone" id="m_phone" />
*</label>
</span></td>
</tr>
<tr>
<td bgcolor="#000066"><span class="style15">Parent's phone number:</span></td>
<td><span class="style17">
<label>
<input type="text" name="m_parphone" id="m_parphone" />
</label>
</span></td>
</tr>
<tr>
<td height="37" bgcolor="#000066"><span class="style15">Level</span></td>
<td><span class="style17">
<select name="m_level" id="m_level">
<option value="A">Admin</option>
<option value="U">User</option>
</select>
*</span></td>
</tr>
<tr>
<td colspan="2" bgcolor="#CCCCCC"><span class="style18">
<label> </label>
</span>
<div align="center" class="style17"> <span class="style18">
<input name="addmember" type="submit" class="style13" id="addmember" value="Add member" />
<input name="reset" type="reset" class="style13" id="reset" value="Reset" />
</span></div>
<span class="style18"> </span></td>
</tr>
</table>

<input type="hidden" name="MM_insert" value="form1" />
</form>
</div>
</body>
</html>
...全文
1675 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
下载代码方式:https://pan.quark.cn/s/a4b39357ea24 依据所提供的资料,我们深入剖析此问题以及所给出的两种算法方案。 ### 问题背景 该问题源自王晓东编撰的《算法设计与实验题解》一书,书中阐述了一个值得注意的数学议题:针对一本页码从1到n顺序编号的书籍,要求统计所有页码中数字0至9各自出现的频次。例如,若n=13,则页码序列为1、2、...、13,其中数字1出现5次(体现在1、10、11、12、13中),数字0出现1次(体现在10中)。 ### 问题描述 具体而言,我们需要开发一种算法,其输入参数为一个正整数n,输出结果需为0至9这十个数字各自出现的频次。所有页码均以十进制形式呈现,且不包含任何前导零,即不会出现如006之类的页码表示。 ### 解决方案一:时间复杂度为O(n*log10(n))的算法 首先,介绍一种时间复杂度为O(n*log10(n))的算法实现。其核心构思在于遍历从1到n的每一个数值,然后逐一分解每个数值的各个位,并统计各类数字出现的频次。具体步骤如下: 1. 初始化一个长度为10的数组`count`,用于记录0至9每个数字出现的频次,初始值均为0。 2. 从1开始遍历至n,对于每一个数值i,将其转换为整数并进行以下操作: - 利用循环结构,持续将当前数值除以10,获取余数(即当前最低位的数字),并累加到对应的计数器中。 3. 遍历完成后,输出`count`数组中的每一个元素,即为所求的结果。 ### 解决方案二:优化算法 为了提升效率,提出了一种更为优越的算法。该算法基于以下观察:在1到10^n-1之间的任意区间内,每一种数字0至9出现的频次是相等的。例如,在1到999之间,每一种数字0至9出现的频次均相...

28,403

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧