Solved

80040e14 Error - Syntax error (missing operator)

Posted on 2004-09-30
7
218 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now