当前位置:编程学习 > asp >>

用Dreamweaver CS5编ASP连接ACCESS, 插入记录老是500错误

用Dreamweaver编ASP连接ACCESS, 插入记录老这样: Microsoft JET Database Engine 错误 '80040e14' INSERT INTO 语句的语法错误。 /main/reg.asp,行 39 但是浏览记录集的网页正常,为什么。源代码如下: <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <!--#include file="../Connections/userinf.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")) = "formreg") Then If (Not MM_abortEdit) Then ' execute the insert Dim MM_editCmd Set MM_editCmd = Server.CreateObject ("ADODB.Command") MM_editCmd.ActiveConnection = MM_userinf_STRING MM_editCmd.CommandText = "INSERT INTO userinf (UserName, PassWord, email, Cool, QQ) VALUES (?, ?, ?, ?, ?)" MM_editCmd.Prepared = true MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 20, Request.Form("UserName")) ' adVarWChar MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 30, Request.Form("PassWord")) ' adVarWChar MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 40, Request.Form("email")) ' adVarWChar MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 203, 1, 536870910, Request.Form("Cool")) ' adLongVarWChar MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 5, 1, -1, MM_IIF(Request.Form("QQ"), Request.Form("QQ"), null)) ' adDouble MM_editCmd.Execute MM_editCmd.ActiveConnection.Close ' append the query string to the redirect URL Dim MM_editRedirectUrl MM_editRedirectUrl = "com.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 %> 略…… <form action="search.asp" method="post" name="form1" target="_blank" id="form1"> 略……
追问:好像是因为PassWord是保留字?
答案:很有可能是类型不对,insert语句那里,你用了几个问号代替,不知道源代码是不是这样。
'"&&"'双引号外有单引号的是字符串类型,"&&"双引号外没有单引号的是数字类型,你检查一下数据库里的字段类型看看匹配不匹配。

上一个:求助:asp.net的Session问题。。。
下一个:服务器asp下载的问题,小文件正常,大文件就500错误,下载是asp语言执行,代码如下

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,