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>
...全文
1561 点赞 收藏 回复
写回复
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2008-11-30 09:57
社区公告
暂无公告