How to use ASP variables in SQL statement

后端 未结 5 1909
北海茫月
北海茫月 2020-11-27 08:43
<%
postit = request.querystring(\"thispost\")
response.write(postit)
%> 

postit is the v

5条回答
  •  迷失自我
    2020-11-27 09:07

    You're not passing the value of postit to Access; instead, you're telling Access to find & use a variable called postit. Of course, said variable doesn't exist in Access -- it only exists in your code. The fix is just a couple of quote marks and a pair of ampersands.

    delCmd.CommandText="DELETE * FROM post WHERE (pos_ID = " & postit & " )"
    

    (Naturally, you should validate postit before you go sending it off to your database. A simple CDbl() can do the trick, assuming it's a numeric value.)

提交回复
热议问题