0

我有一个简单的 ASP 页面,它应该根据传入的变量删除或插入一行。我有类似的文件可以正常工作,但是这个不工作......即使没有错误并且 response.write 检查工作正常。我什至尝试使用文字值但没有运气。有任何想法吗?这是代码:

<%  
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"
%>
4

1 回答 1

2

您正在使用一个名为“tid”的变量,如下所示:

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

但是,您在 SQL 字符串中使用了其他名为“id”的内容,如下所示:

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

也许只是一个错字,也许还缺少其他东西?

于 2013-08-20T16:27:13.887 回答