Forums
This topic is locked
Syntax error when uploaded to server
Posted 12 May 2004 20:53:58
1
has voted
12 May 2004 20:53:58 jackie goldsmith posted:
Microsoft JET Database Engine error '80040e14' Syntax error in UPDATE statement.
/test/update.asp, line 89
line 84-90 looks like this
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
Edited by - jackieg on 12 May 2004 21:02:50
Replies
Replied 12 May 2004 21:28:13
12 May 2004 21:28:13 Vince Baker replied:
You will need to paste your whole page here as the sql command that is causing the error is not shown in the code your pasted here.
Regards
Vince
DMX Talkzone Manager
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Regards
Vince
DMX Talkzone Manager
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Replied 12 May 2004 21:43:19
12 May 2004 21:43:19 jackie goldsmith replied:
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/conn_project_test.asp" -->
<%
' *** Edit Operations: declare variables
MM_editAction = CStr(Request("URL"
)
If (Request.QueryString <> ""
Then
MM_editAction = MM_editAction & "?" & 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"
) <> "" And CStr(Request("MM_recordId"
) <> ""
Then
MM_editConnection = MM_conn_project_test_STRING
MM_editTable = "Projects"
MM_editColumn = "Project_ID"
MM_recordId = "" + Request.Form("MM_recordId"
+ ""
MM_editRedirectUrl = "projects.asp"
MM_fieldsStr = "Project Name|value|Project Description|value|Actions|value|Status|value|Completed|value|Phasae|value"
MM_columnsStr = "[Project Title]|',none,''|[Project Description]|',none,''|Action|',none,''|Status|',none,''|[Completion Date]|',none,NULL|Phase|none,none,NULL"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"
' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(Request.Form(MM_fields(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 i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),","
Delim = MM_typeArray(0)
If (Delim = "none"
Then Delim = ""
AltVal = MM_typeArray(1)
If (AltVal = "none"
Then AltVal = ""
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none"
Then EmptyVal = ""
If (FormVal = ""
Then
FormVal = EmptyVal
Else
If (AltVal <> ""
Then
FormVal = AltVal
ElseIf (Delim = "'"
Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''"
& "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(i) & " = " & 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 Recordset1__MMColParam
Recordset1__MMColParam = "1"
if (Request.QueryString("Project_ID"
<> ""
then Recordset1__MMColParam = Request.QueryString("Project_ID"
%>
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset"
Recordset1.ActiveConnection = MM_conn_project_test_STRING
Recordset1.Source = "SELECT * FROM Projects WHERE Project_ID = " + Replace(Recordset1__MMColParam, "'", "''"
+ ""
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><font size="2" face="Arial, Helvetica, sans-serif">Update Record<b><i> <%=(Recordset1.Fields.Item("Project_ID"
.Value)%></i></b></font></p>
<form METHOD="POST" name="form1" action="<%=MM_editAction%>">
<table width="882" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="146"><font size="2" face="Arial, Helvetica, sans-serif">Project
Name</font></td>
<td width="736"> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="text" name="Project Name" size="100" value="<%=(Recordset1.Fields.Item("Project Title"
.Value)%>">
</font></td>
</tr>
<tr>
<td width="146"><font size="2" face="Arial, Helvetica, sans-serif">Project
Description</font></td>
<td width="736"> <font size="2" face="Arial, Helvetica, sans-serif">
<textarea name="Project Description" cols="75" rows="3"><%=(Recordset1.Fields.Item("Project Description"
.Value)%></textarea>
</font></td>
</tr>
<tr>
<td width="146"><font size="2" face="Arial, Helvetica, sans-serif">Notes</font></td>
<td width="736"> <font size="2" face="Arial, Helvetica, sans-serif">
<textarea name="Actions" rows="3" cols="75"><%=(Recordset1.Fields.Item("Action"
.Value)%></textarea>
</font></td>
</tr>
<tr>
<td width="146"><font size="2" face="Arial, Helvetica, sans-serif">Status</font></td>
<td width="736"> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="text" name="Status" value="<%=(Recordset1.Fields.Item("Status"
.Value)%>">
</font></td>
</tr>
<tr>
<td width="146"><font size="2" face="Arial, Helvetica, sans-serif">Completed
Date</font></td>
<td width="736"> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="text" name="Completed" value="<%=(Recordset1.Fields.Item("Completion Date"
.Value)%>">
</font></td>
</tr>
<tr>
<td width="146"><font size="2" face="Arial, Helvetica, sans-serif">Phase</font></td>
<td width="736"> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="text" name="Phasae" value="<%=(Recordset1.Fields.Item("Phase"
.Value)%>">
</font></td>
</tr>
<tr>
<td width="146">
<input type="submit" name="Submit" value="Submit">
</td>
</tr>
</table>
<input type="hidden" name="MM_update" value="true">
<input type="hidden" name="MM_recordId" value="<%= Recordset1.Fields.Item("Project_ID"
.Value %>">
</form>
<p> </p>
</body>
</html>
<%
Recordset1.Close()
%>
Edited by - jackieg on 12 May 2004 21:46:19
<!--#include file="Connections/conn_project_test.asp" -->
<%
' *** Edit Operations: declare variables
MM_editAction = CStr(Request("URL"

If (Request.QueryString <> ""

MM_editAction = MM_editAction & "?" & 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"



MM_editConnection = MM_conn_project_test_STRING
MM_editTable = "Projects"
MM_editColumn = "Project_ID"
MM_recordId = "" + Request.Form("MM_recordId"

MM_editRedirectUrl = "projects.asp"
MM_fieldsStr = "Project Name|value|Project Description|value|Actions|value|Status|value|Completed|value|Phasae|value"
MM_columnsStr = "[Project Title]|',none,''|[Project Description]|',none,''|Action|',none,''|Status|',none,''|[Completion Date]|',none,NULL|Phase|none,none,NULL"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"

MM_columns = Split(MM_columnsStr, "|"

' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> ""

If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> ""

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"



' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),","

Delim = MM_typeArray(0)
If (Delim = "none"

AltVal = MM_typeArray(1)
If (AltVal = "none"

EmptyVal = MM_typeArray(2)
If (EmptyVal = "none"

If (FormVal = ""

FormVal = EmptyVal
Else
If (AltVal <> ""

FormVal = AltVal
ElseIf (Delim = "'"

FormVal = "'" & Replace(FormVal,"'","''"

Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(i) & " = " & 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 <> ""

Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
if (Request.QueryString("Project_ID"



%>
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset"

Recordset1.ActiveConnection = MM_conn_project_test_STRING
Recordset1.Source = "SELECT * FROM Projects WHERE Project_ID = " + Replace(Recordset1__MMColParam, "'", "''"

Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><font size="2" face="Arial, Helvetica, sans-serif">Update Record<b><i> <%=(Recordset1.Fields.Item("Project_ID"

<form METHOD="POST" name="form1" action="<%=MM_editAction%>">
<table width="882" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="146"><font size="2" face="Arial, Helvetica, sans-serif">Project
Name</font></td>
<td width="736"> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="text" name="Project Name" size="100" value="<%=(Recordset1.Fields.Item("Project Title"

</font></td>
</tr>
<tr>
<td width="146"><font size="2" face="Arial, Helvetica, sans-serif">Project
Description</font></td>
<td width="736"> <font size="2" face="Arial, Helvetica, sans-serif">
<textarea name="Project Description" cols="75" rows="3"><%=(Recordset1.Fields.Item("Project Description"

</font></td>
</tr>
<tr>
<td width="146"><font size="2" face="Arial, Helvetica, sans-serif">Notes</font></td>
<td width="736"> <font size="2" face="Arial, Helvetica, sans-serif">
<textarea name="Actions" rows="3" cols="75"><%=(Recordset1.Fields.Item("Action"

</font></td>
</tr>
<tr>
<td width="146"><font size="2" face="Arial, Helvetica, sans-serif">Status</font></td>
<td width="736"> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="text" name="Status" value="<%=(Recordset1.Fields.Item("Status"

</font></td>
</tr>
<tr>
<td width="146"><font size="2" face="Arial, Helvetica, sans-serif">Completed
Date</font></td>
<td width="736"> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="text" name="Completed" value="<%=(Recordset1.Fields.Item("Completion Date"

</font></td>
</tr>
<tr>
<td width="146"><font size="2" face="Arial, Helvetica, sans-serif">Phase</font></td>
<td width="736"> <font size="2" face="Arial, Helvetica, sans-serif">
<input type="text" name="Phasae" value="<%=(Recordset1.Fields.Item("Phase"

</font></td>
</tr>
<tr>
<td width="146">
<input type="submit" name="Submit" value="Submit">
</td>
</tr>
</table>
<input type="hidden" name="MM_update" value="true">
<input type="hidden" name="MM_recordId" value="<%= Recordset1.Fields.Item("Project_ID"

</form>
<p> </p>
</body>
</html>
<%
Recordset1.Close()
%>
Edited by - jackieg on 12 May 2004 21:46:19