|
主题: 有个关于数据库连接问题
|
Dreamer
职务:普通成员
等级:1
金币:1.0
发贴:133
|
#12004/6/1 17:17:52
我在做一个可以修改数据库里内容的网页时候,老是不能修改 说我有错误 如下 引用: Microsoft VBScript 编译器错误 错误 '800a03f6'
缺少 'End'
/iisHelp/common/500-100.asp,行242
Microsoft JET Database Engine 错误 '80040e14'
UPDATE 语句的语法错误。
/ylz/edit.asp,行131
那个页面的代码 引用: <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <!--#include file="Connections/conn.asp" --> <% ' *** Restrict Access To Page: Grant or deny access to this page MM_authorizedUsers="" MM_authFailedURL="login.asp" MM_grantAccess=false If Session("MM_Username" <> "" Then If (true Or CStr(Session("MM_UserAuthorization")="" Or _ (InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization")>=1) Then MM_grantAccess = true End If End If If Not MM_grantAccess Then MM_qsChar = "?" If (InStr(1,MM_authFailedURL,"?" >= 1) Then MM_qsChar = "&" MM_referrer = Request.ServerVariables("URL" if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString() MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer) Response.Redirect(MM_authFailedURL) End If %> <% ' *** 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_conn_STRING MM_editTable = "noticeboard" MM_editColumn = "ID" MM_recordId = "" + Request.Form("MM_recordId" + "" MM_editRedirectUrl = "admin.asp" MM_fieldsStr = "date|value|content|value" MM_columnsStr = "date|',none,''|content|',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 rs__MMColParam rs__MMColParam = "1" If (Request.QueryString("ID" <> "" Then rs__MMColParam = Request.QueryString("ID" End If %> <% Dim rs Dim rs_numRows
Set rs = Server.CreateObject("ADODB.Recordset" rs.ActiveConnection = MM_conn_STRING rs.Source = "SELECT * FROM noticeboard WHERE ID = " + Replace(rs__MMColParam, "'", "''" + "" rs.CursorType = 0 rs.CursorLocation = 2 rs.LockType = 1 rs.Open()
rs_numRows = 0 %> <% Function HTMLEncode(Str) Str=Replace(Str,"<","<" '把Str中的"<"替换成"<" Str=Replace(Str,">",">" '把Str中的">"替换成">",跟上面这行一起是屏蔽HTML代码的 Str=Replace(Str," "," " '把Str中的" "替换成" ",解决多个连续空格只显示一个的问题 Str=Replace(Str,Chr(10),"<br>" '把Str中的回车符替换成"<br>",解决回车换行无效的问题 HTMLEncode=Str '返回经过上面字符替换后的Str End Function %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>公告栏-管理-修改</title> <style type="text/css"> <!-- .style1 { font-family: "宋体"; font-size: 14px; } --> </style> </head>
<body> <p> </p> <table width="600" height="216" border="1" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="40" align="center"><span class="style1">公告栏-管理-修改</span></td> </tr> <tr> <td> <p> </p> <form method="post" action="<%=MM_editAction%>" name="form1"> <table align="center"> <tr valign="baseline"> <td nowrap align="right">日期:</td> <td><input name="date" type="text" value="<%=(rs.Fields.Item("date".value)%>" size="32"> </td> </tr> <tr> <td nowrap align="right" valign="top">内容:</td> <td valign="baseline"><textarea name="content" cols="50"><%= Server.HTMLEncode((rs.Fields.Item("content".value)) %></textarea> </td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input name="Submit" type="submit" id="Submit" value="修改"> <input name="Reset" type="reset" id="Reset" value="重置"> </td> </tr> </table> <input type="hidden" name="MM_update" value="form1"> <input type="hidden" name="MM_recordId" value="<%= rs.Fields.Item("ID".value %>"> </form> <p> </p> <p> </p></td> </tr> </table>
<p> </p> </body> </html> <% rs.Close() Set rs = Nothing %>
|
Dreamer
职务:普通成员
等级:1
金币:1.0
发贴:133
|
#22004/6/1 17:19:12
那个笑脸是右括号
|
绿茶
职务:普通成员
等级:8
金币:10.0
发贴:19267
|
#32004/6/1 18:24:35
不是说了语法错误了啊,你这样用FOR循环来进行字段更新,有些数据类型会出错的,故,你可以把那句更新语句打印出来,看看是否有哪些地方不符合语法
|
Dreamer
职务:普通成员
等级:1
金币:1.0
发贴:133
|
#42004/6/1 20:12:27
我是用dereamweaver mx 2004 做的 程序它自动编的 所以不大懂的啊
|
浮尘
职务:普通成员
等级:3
金币:7.0
发贴:1258
|
#52004/6/1 23:01:20
这么长,还没看我就晕了。
|