Solved

80040e14 Error - Syntax error (missing operator)

Posted on 2004-09-30
7
222 Views
Last Modified: 2008-02-26
I keep getting an error (80040e14) when I try to delete a record in the table. I am passing the id of the record from a link created dynamicly from that table.

Here is the code for the page to delete the record:

<%@LANGUAGE="VBSCRIPT"%>
<!--#include virtual="../DB/connection.asp" -->
<%
microlab_id = Request.QueryString("id")
%>
<%
Response.Write("Id = " & microlab_id)
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language="javascript" type="text/javascript">
function cfm(msg) {
if (confirm(msg)) {
return true
} else {
return false
}}
</script>
<title>List of Microlabs</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table border="1">
<tr><td>Title</td><td>Discription</td><td>Edit</td><td>Delete</td></tr>
<%
objSql = "microlabs"
Dim objConn
Set objConn = Server.CreateObject("ADODB.Recordset")
objConn.Source = objSql
objConn.ActiveConnection = conn.ConnectionString
objConn.CursorType = adOpenStatic
objConn.Open
Do While Not objConn.EOF
Response.Write("<tr>")
Response.Write("<td>" & objConn("micro_title") & "</td>")
Response.Write("<td>" & objConn("micro_discription") & "</td>")
Response.Write("<td><a href=edit.asp?id=" & objConn("micro_id") & ">Edit</td>")
Response.Write("<td><a href=delete.asp?id=" & objConn("micro_id") & " onClick=""" & "cfm('" & objConn("micro_discription") & "')"" " & ">Delete</td>")
Response.Write("</tr>")
objConn.MoveNext
Loop
objConn.Close
Set objConn = Nothing
conn.Close
Set conn = Nothing
%>
</table>
</body>
</html>

Here is the page to delete the record:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include virtual="../DB/connection.asp" -->
<%
microlab_id = Request.QueryString("id")
%>
<%=Response.Write("Id = " & microlab_id)%>
<%
idFound = False
'Gets a list of all Microlabs listed in the DB
objSelSQL = "microlabs"
Dim objSel
Set objSel = Server.CreateObject("ADODB.Recordset")
objSel.Source = objSelSQL
objSel.ActiveConnection = conn.ConnectionString
objSel.CursorType = adLockOptimistic
objSel.Open

Dim objDel
Set objDel = Server.CreateObject("ADODB.Recordset")
objDel.ActiveConnection = conn.ConnectionString
objDel.CursorType = adLockOptimistic
objDel.SQL = "Delete from microlabs Where micro_id = " & microlab_id & ""
objDel.Open SQL

Do While Not (objSel.EOF OR idFound)
If (StrComp(objSel("micro_id"), id, 1) = 0) Then
idFound = True
Else
objSel.MoveNext
End If
Loop

If (StrComp(idFound, "True", 1) = 0) Then
Response.Redirect("error.asp?errorID=1001")
End If
objSel.Close
objSel = Nothing
objDel.Close
objDel = Nothing
conn.Close
conn = Nothing
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Deleted (<%=id%>)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="refresh" content="1;URL=show_micro.asp">
</head>
<body>
Microlab #<%=id%>, has now been deleted. You are being redirected back.
</body>
</html>

What am I doing wrong?
0
Comment
Question by:chadreeves1
  • 3
  • 2
  • 2
7 Comments
 
LVL 10

Accepted Solution

by:
m8rix earned 75 total points
ID: 12196659
Try and replace this line of code:

objDel.SQL = "Delete from microlabs Where micro_id = " & microlab_id & ""

With

objDel.SQL = "Delete from microlabs Where micro_id = " & microlab_id
0
 
LVL 15

Assisted Solution

by:joeposter649
joeposter649 earned 75 total points
ID: 12200059
I think you want more in this line...
objSelSQL = "microlabs"

Perhaps you're trying to do something like this...
objSelSQL  = "Select * from microlabs Where micro_id = " & microlab_id
Then check  objSel EOF before doing the delete.

Unrelated to your error but I think you want your onclick to look return cfm()...
Response.Write("<td><a href=delete.asp?id=" & objConn("micro_id") & " onClick=""" & "return cfm('" & objConn("micro_discription") & "')"" " & ">Delete</td>")

0
 
LVL 10

Expert Comment

by:m8rix
ID: 12213589
How did you go chadreeves1?
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 1

Author Comment

by:chadreeves1
ID: 12220741
Sorry Guys I have tried everything you were saying and nothing has worked I get a "Syntax error (missing operator) in query expression 'micro_id ='." With the code:<%
objSelSQL = "Select * from microlabs Where micro_id = " + microlab_id
Dim objSel
Set objSel = Server.CreateObject("ADODB.Recordset")
objSel.Source = objSelSQL
objSel.ActiveConnection = conn.ConnectionString
objSel.CursorType = adOpenDynamic
objSel.Open
'Acutally Deletes the givin record from the DB
objSel.Delete adAffectCurrent
objSel.Close
objSel = Nothing
conn.Close
conn = Nothing
%>

or the same error if I change it back.

Sorry it took me so long to respond I had a wedding to go to and I wasn't able to access the website to make any changes.
0
 
LVL 15

Expert Comment

by:joeposter649
ID: 12220870
What line is the error on?
Try this...
objSelSQL = "Select * from microlabs Where micro_id = '" & microlab_id & "'"

You might also want do this...
microlab_id = trim(Request.QueryString("id"))
0
 
LVL 1

Author Comment

by:chadreeves1
ID: 12221126
The error is on line 21
0
 
LVL 1

Author Comment

by:chadreeves1
ID: 12222038
I figuried out what was wrong. I recently changed the directory my page was in and forgot to update the links so all it was giving me was a cashed page from earlyer. when I go to the new page I get no problem that you all for your help I have split up the points evenly between you.

Thank you,
chadreeves1
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBScript FormatCurrency - how to change the currency symbol 4 46
Choose the older file FSO 6 47
Server Timeout with Loop 6 45
Questions about INCLUDE FILES 2 31
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question