ASP经典插入/删除SQL查询没有错误,但不工作。

时间:2022-11-26 01:39:30

I have a simple ASP page that should delete or insert a row based on passed-in variables. I have similar files that work fine, but this one does not work... even though there are no errors and the response.write checks work fine. I even tried using literal values with no luck. Any ideas? Here is the code:

我有一个简单的ASP页面,它应该删除或插入基于传入变量的行。我有类似的文件可以正常工作,但是这个不行……即使没有错误和响应。写检查。我甚至试着用文字值,但没有运气。什么好主意吗?这是代码:

<%  
dim tid
dim email
dim joinOrUnjoin
tid = UCase(Request.Form("thisID"))
email = UCase(Request.Form("email"))
joinOrUnjoin = UCase(Request.Form("joinOrUnjoin"))

dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=SQLOLEDB;Server=*********;Database=Reports;User Id=**********;Password=***********;"
objConn.mode = 3
objConn.Open

if LCase(joinOrUnjoin) = "join" then

    strSQL = "INSERT INTO SSOcomEmailDistribution (ID, Email) VALUES ('" & id & "', '" & email & "')"
    Response.write "Join"
else

    strSQL = "DELETE From SSOcomEmailDistribution WHERE ID='" & id & "' AND Email='" & email & "'"
    Response.write "Unjoin " & id & " " & email
end if

objConn.Execute(strSQL)
objConn.Close()

Response.write " Done"
%>

1 个解决方案

#1


2  

You are using a variable named "tid" like this:

您正在使用一个名为“tid”的变量:

tid = UCase(Request.Form("thisID"))

but then, you use something else named "id" in your SQL string, like this:

但是,您在SQL字符串中使用了另一个名为“id”的名称,如下所示:

strSQL = "INSERT INTO SSOcomEmailDistribution (ID, Email) VALUES ('" & id & "', '" & email & "')"

maybe just a typo, maybe something else is missing?

可能只是打错了,可能还缺什么?

#1


2  

You are using a variable named "tid" like this:

您正在使用一个名为“tid”的变量:

tid = UCase(Request.Form("thisID"))

but then, you use something else named "id" in your SQL string, like this:

但是,您在SQL字符串中使用了另一个名为“id”的名称,如下所示:

strSQL = "INSERT INTO SSOcomEmailDistribution (ID, Email) VALUES ('" & id & "', '" & email & "')"

maybe just a typo, maybe something else is missing?

可能只是打错了,可能还缺什么?