0

我有一个完成数据库查找的页面,如果找到一个值,则会将一些响应发送回用户,然后删除数据库值。

在我检查了变量之后,我正在调用我的删除子程序,但这就像从未发生过一样,尽管我知道子程序已经运行,因为该值现在已经从数据库中消失了。

页面似乎加载了两次,在第二次通过时数据库值已经消失,因此它显示好像从未找到数据库值,但必须找到它才能删除它(因为这是一个条件用于运行删除子)。

我意识到这听起来很疯狂,但我已经做了 2 天了,不知道发生了什么。我已经尝试从 IIS 中禁用缓存并更改我的代码,以便将值发布到数据库而不是删除记录,我仍然得到相同的东西,我的服务器似乎在调用之前检查数据库的未来值改变它的例程。

在单个页面上读取和写入同一记录时,有没有人看到过类似的行为?

代码:

referer = Request.ServerVariables ("HTTP_REFERER")
session("testcode") = right(referer,16)

testcode = session("testcode")

set objcommand = server.createObject("adodb.command")
objcommand.activeconnection = strconnect2
objcommand.commandtext="SELECT codeval,stamp,used from code where     codeval like '" & testcode & "'"
objcommand.commandtype = 1
set objrs = objcommand.Execute
set objcommand = nothing 
countvar = 0

While not objrs.EOF

    if not objrs("used") = true then
        foundcode = true
        countvar = countvar+1
    end if


    objrs.MoveNext
wend


if foundcode = true then
    response.write "Found you!"

    set objcomm5 = server.createobject("adodb.command") 
    objcomm5.activeconnection = strconnect2 
    objcomm5.commandtext = "update code set used = true where codeval like '"&     testcode &"' " 
    objcomm5.commandtype = &H0001

    objcomm5.execute
else
    response.write "Can't be found!"
end if
4

0 回答 0