What am I doing wrong??_ASP_

Jack Michaelson's picture

He has: 1,733 posts

Joined: Dec 1999

I want the user to type an index of a db and when he hits the submit-button the current recordset is deleted.
It works when the indextype=text, but now I made the indextype Autonumber. So I had to convert the var from string to number.
The convertion works, but the SQL-statement says:

Code Sample:

Microsoft OLE DB Provider for ODBC Drivers Error '80040e7'
[Microsoft][microsoft Acces 97 Driver] Data type mismatch in criteria expression.

I don't understand. Who does??
Here's the code:

Code Sample:

<form method="get" id="form1" name="form1" action="del.asp">
<hr>

<br>
<table name=table>
<tr>
<td>
<input type="text" name="dele">
<input type="submit" value="Delete"> </td>
</tr>
</table>

<%

deleted=Request.Querystring ("dele")
deleted=Cint(Request.Querystring ("dele"))


rs2.Open "Select * from orders where idnr='"&deleted&"'", Conn, adOpenDynamic, 4
if rs2.EOF then
if Len(Request.QueryString("dele")) <> 0 then
Response.Redirect("delwrong.asp")
rs2.close
end if
else
rs2.close
rs2.Open "Delete from orders where idnr='"&deleted&'", Conn, adOpenDynamic, 4

end if

%>
<br><%
Response.write dele%>
<% MyConn.Close
set Myconn = nothing %>
</form>

PLS REPLY.

------------------
Jack Michaelson
[email protected]
! Click here for my profile !

[This message has been edited by Jack Michaelson (edited 16 December 1999).]

Shakespeare: onclick || !(onclick)

They have: 3 posts

Joined: Mar 2000

try out
rs2.Open "Delete from orders where idnr="&deleted&", Conn, adOpenDynamic, 4

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

Jack,

Looks like you're missing an "'", try this:

rs2.Open "Delete from orders where idnr='"&deleted&"'", Conn, adOpenDynamic, 4

Plus it's just my personal preference but I like to put spaces inbetween like this:

idnr = '" & deleted & "'"

It makes the code easier to read and debug.

Regards,
Peter J. Boettcher

PJ | Are we there yet?
pjboettcher.com

Jack Michaelson's picture

He has: 1,733 posts

Joined: Dec 1999

Solved it myself already,

Thanx anyway.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.