Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

...: I've been looking at this code for 2 long to find the problem :.. 4

Status
Not open for further replies.

TonyU

Technical User
Feb 14, 2001
1,317
US
[tt]
Here's the problem and would appreciate your help fellas.

The Link

<div align=&quot;center&quot;><font color=&quot;#FF0000&quot;><a href=&quot;deleterecords2.asp?id=<%=(RS(&quot;id&quot;).value)%>&quot;>Delete</a></font></div>

As you can see, I'm passing the <%=(RS(&quot;id&quot;).value)%> over to deleterecords2.asp.


The processing page

<%@LANGUAGE=&quot;VBSCRIPT&quot;%>
<!--#include file=&quot;Connections/MYDSN.asp&quot; -->
<%
Dim deleteme__MMColParam
deleteme__MMColParam = &quot;1&quot;
if (Request.QueryString(&quot;id&quot;) <> &quot;&quot;) then deleteme__MMColParam = Request.QueryString(&quot;id&quot;)
%>
<%
set deleteme = Server.CreateObject(&quot;ADODB.Recordset&quot;)
deleteme.ActiveConnection = MM_MYDSN_STRING
deleteme.Source = &quot;SELECT * FROM tblUsers WHERE id = &quot; + Replace(deleteme__MMColParam, &quot;'&quot;, &quot;''&quot;) + &quot;&quot;
deleteme.CursorType = 0
deleteme.CursorLocation = 2
deleteme.LockType = 3
deleteme.Open()
deleteme_numRows = 0
%>
<%
deleteme.delete
response.redirect &quot;results.asp&quot;
%>
<%
deleteme.Close()
%>

The error I'm getting

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

Query-based delete failed because the row to delete could not be found.

'I have 3 records in my Access databaes with id's 10,11,12 so I know the records exists.


/USERS/deleterecords2.asp, line 20


Line 20

deleteme.delete




Thanks in advance...
[tt]&quot;A Successful man is one who can build a firm foundation with the bricks that others throw at him&quot;[/tt]
[noevil]
 
if you response.write the sql source line, what is the value of the line? ie what is the id?

Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
[tt]it's blank now that you mention it. but I see it in the url tho
[tt]&quot;A Successful man is one who can build a firm foundation with the bricks that others throw at him&quot;[/tt]
[noevil]
 
[tt]Could someone else please check this code for me? thanks
[tt]&quot;A Successful man is one who can build
a firm foundation with the bricks
that others throw at him&quot;
[/tt]

star.gif
star.gif
star.gif
star.gif

 
hi

<a href=&quot;deleterecords2.asp?id='<%=(RS(&quot;id&quot;).value)%>'&quot;>Delete</a></font></div>

put single quote before <%= and after %> then check

 
Try changing your concatenation operator in your SQL string to & instead of +:

deleteme.Source = &quot;SELECT * FROM tblUsers WHERE id = &quot; & Replace(deleteme__MMColParam, &quot;'&quot;, &quot;''&quot;)


Also, is ID a number field or a character field? If character you need to place it in single quotes. If it is number type, you should not need to do the Replace function:

deleteme.Source = &quot;SELECT * FROM tblUsers WHERE id = '&quot; & Replace(deleteme__MMColParam, &quot;'&quot;, &quot;''&quot;) & &quot;'&quot;

Try that out and see what happens.
 
[tt]
coolasp: the field is numberic not character

JuanitaC: I've changed both +'s to &'s and still get the line 20 error

should & Replace(deleteme__MMColParam, be within quotes? I'm not good with concatenation at all

thanks for the help
[tt]&quot;A Successful man is one who can build
a firm foundation with the bricks
that others throw at him&quot;
[/tt]

star.gif
star.gif
star.gif
star.gif

 
Even if the field is numeric in the href you can only have the one set of &quot; &quot; unless you use the chr function. Taht was why it was pointed out. You actually have none in around the RS which are needed.
That may be why your SQL statement is empty when you write it out You cannot mandate productivity, you must provide the tools to let people become their best.
-Steve Jobs
admin@onpntwebdesigns.com
 
OK... if your id is numeric, then you shouldn't need the Replace function at all:

deleteme.Source = &quot;SELECT * FROM tblUsers WHERE id = &quot; & deleteme__MMColParam

Right after this line, write it out so you can see how it is being built:

Response.write(&quot;SQL is &quot; & deleteme.Source & &quot;<br>&quot;)
Response.end
 
TonyU,

Try this.

<a href=&quot;deleterecords2.asp?id='<%=RS(&quot;&quot;id&quot;&quot;)%>'&quot;>Delete</a></font></div>

The rule is: If you are using two double quotes on the outside of a string, then all double quotes on the inside must contain two.

fengshui_1998
 
In this case, the quotes in building the querystring do not matter. Everything between the <% %> is executed Server-side, therefore <%=rs(&quot;ID&quot;)%> is actually writing the value in the HTML, so
<a href=&quot;deleterecords2.asp?id=<%=RS(&quot;id&quot;)%>&quot;>Delete</a></font></div>

will write
<a href=&quot;deleterecords2.asp?id=10&quot;>Delete</a></font></div>

which is what it should be.

 
[tt] Ok, I'm getting somewhere here now. JuanitaC
with your suggestions of
deleteme.Source = &quot;SELECT * FROM tblUsers WHERE id = &quot; & deleteme__MMColParam

Right after this line, write it out so you can see how it is being built:

Response.write(&quot;SQL is &quot; & deleteme.Source & &quot;<br>&quot;)
Response.end

My SQl was displayed as follows:
SQL is SELECT * FROM tblUsers WHERE id = 12

But
when I comment this line out
' Response.write(&quot;SQL is &quot; & deleteme.Source & &quot;<br>&quot;)
Response.end

the page simply hangs without re-directing to the results.asp page.
[tt]&quot;A Successful man is one who can build
a firm foundation with the bricks
that others throw at him&quot;
[/tt]

star.gif
star.gif
star.gif
star.gif

 
Never mind guys, it was hanging because I did not comment out the &quot;response.end&quot; line.

Feng, your suggestions worked so did JuanitaC's but I'm still getting the line 20 error

Line 20

deleteme.delete









[tt]&quot;A Successful man is one who can build
a firm foundation with the bricks
that others throw at him&quot;
[/tt]

star.gif
star.gif
star.gif
star.gif

 
[tt]Is it possible that the like deleteme.delete should be something else? Just thinking outloud here.
[tt]&quot;A Successful man is one who can build
a firm foundation with the bricks
that others throw at him&quot;
[/tt]

star.gif
star.gif
star.gif
star.gif

 
Is there a reason that you want to delete using the recordset object? I find just executing SQL statements on a Connection object to be much easier:

set dbconn = Server.createobject(&quot;Adodb.connection&quot;)
dbconn.Open connection_string, user, password
SQL = &quot;DELETE FROM tblUsers WHERE id = &quot; & deleteme__MMColParam

DBConn.Execute(SQL)
DBConn.Close()
Set DBConn=Nothing
Response.Redirect....
 
[tt]I was simply trying to modify a (to the best of my ability) snippet someone gave me on my own before running into these issues.

I'll use whatever is thrown at me right now, you're last suggestion sound good to me. Can you guide me as to how and where to use the code within mine?
[tt]&quot;A Successful man is one who can build
a firm foundation with the bricks
that others throw at him&quot;
[/tt]

star.gif
star.gif
star.gif
star.gif

 
[tt]I GOT IT!!!!!!!!!!!!!!
[tt]I GOT IT!!!!!!!!!!!!!!
[tt]I GOT IT!!!!!!!!!!!!!!


Thanks to all that contributed to my headache.

star.gif
star.gif
star.gif
star.gif
for all.


[tt]&quot;A Successful man is one who can build
a firm foundation with the bricks
that others throw at him&quot;
[/tt]

star.gif
star.gif
star.gif
star.gif

 
[tt]
Here what I changed based on your last suggestion

<%@LANGUAGE=&quot;VBSCRIPT&quot;%>
<!--#include file=&quot;Connections/MYDSN.asp&quot; -->
<%
Dim deleteme__MMColParam
deleteme__MMColParam = &quot;1&quot;
if (Request.QueryString(&quot;id&quot;) <> &quot;&quot;) then deleteme__MMColParam = Request.QueryString(&quot;id&quot;)
%>
<%
set deleteme = Server.CreateObject(&quot;ADODB.Recordset&quot;)
deleteme.ActiveConnection = MM_MYDSN_STRING
deleteme.Source = &quot;DELETE * FROM tblUsers WHERE id = &quot; & Replace(deleteme__MMColParam
deleteme.CursorType = 0
deleteme.CursorLocation = 2
deleteme.LockType = 3
deleteme.Open()
deleteme_numRows = 0
%>
<%
I commented this line out ' deleteme.delete
response.redirect &quot;results.asp&quot;
%>
<%
deleteme.Close()
%>








[tt]&quot;A Successful man is one who can build
a firm foundation with the bricks
that others throw at him&quot;
[/tt]

star.gif
star.gif
star.gif
star.gif

 
Glad it is working, just one quick point: you don't need the * when you are deleting:

deleteme.Source = &quot;DELETE FROM tblUsers WHERE id = &quot; & Replace(deleteme__MMColParam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top