|
在執行插入記錄的動作時,出現一個錯誤訊息,如下:
技術資訊 (供技術支援人員使用)
錯誤類型: Microsoft JET Database Engine (0x80040E14) INSERT INTO 陳述式的語法錯誤。 /add.asp, line 26
瀏覽器類型: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727)
頁數: POST 57 bytes to /add.asp
POST Data: username=kik&password=kkk&Submit=%B0e%A5X&MM_insert=form1
我把全部的原始碼貼上來: <%@LANGUAGE="VBSCRIPT" CODEPAGE="950"%> <!--#include file="Connections/connNews.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 %> <% 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_connNews_STRING MM_editCmd.CommandText = "INSERT INTO [admin] (username, password) VALUES (?, ?)" MM_editCmd.Prepared = true MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 201, 1, 50, Request.Form("username")) ' adLongVarChar MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 201, 1, 50, Request.Form("password")) ' adLongVarChar MM_editCmd.Execute MM_editCmd.ActiveConnection.Close
' append the query string to the redirect URL Dim MM_editRedirectUrl MM_editRedirectUrl = "admin.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 %> <% Dim Recordset1 Dim Recordset1_cmd Dim Recordset1_numRows
Set Recordset1_cmd = Server.CreateObject ("ADODB.Command") Recordset1_cmd.ActiveConnection = MM_connNews_STRING Recordset1_cmd.CommandText = "SELECT * FROM [admin] ORDER BY id ASC" Recordset1_cmd.Prepared = true
Set Recordset1 = Recordset1_cmd.Execute 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=big5" /> <title>無標題文件</title> </head>
<body> <form ACTION="<%=MM_editAction%>" METHOD="POST" id="form1" name="form1"> <table width="500" border="1" align="center"> <tr> <td> </td> <td> </td> </tr> <tr> <td>username</td> <td><label> <input name="username" type="text" id="username" /> </label></td> </tr> <tr> <td>password</td> <td><label> <input name="password" type="text" id="password" /> </label></td> </tr> <tr> <td> </td> <td><label> <input type="submit" name="Submit" value="送出" /> </label></td> </tr> <tr> <td> </td> <td> </td> </tr> </table>
<input type="hidden" name="MM_insert" value="form1"> </form> </body> </html> <% Recordset1.Close() Set Recordset1 = Nothing %>
我參照互動網站百寶箱For Asp全新修訂版的步驟測試,結果都是這樣,請幫幫忙,幫忙看一下! 謝謝 |