我有一个经典的ASP页面,其中包含一些代码以检查表中是否存在电子邮件,如下所示;检查电子邮件是否存在
<%
'' //Check the submitted email against existing ones in the database
set CmdCheckEmail = server.CreateObject("ADODB.Command")
CmdCheckEmail.ActiveConnection = MM_dbconn_STRING
CmdCheckEmail.CommandText = "SELECT COUNT(ReferredEmail) AS 'CountEmail' FROM TenantReferral WHERE ReferredEmail = '" & Request("Email") & "'"
Response.Write(CmdCheckEmail.CommandText)
CmdCheckEmail.CommandType = 1
CmdCheckEmail.CommandTimeout = 0
CmdCheckEmail.Prepared = true
CmdCheckEmail.Execute()
countEmail = CmdCheckEmail("CountEmail")
set CmdCheckEmail = nothing
conn.close
set conn = nothing
If(countEmail >= 1) Then
Message = Message & "<p>This email address has already been referred.</p>"
End If
%>
但是,页面正在报告以下错误;
SELECT COUNT(ReferredEmail) AS 'CountEmail' FROM TenantReferral WHERE ReferredEmail = '[email protected]'
ADODB.Command error '800a0cc1'
Item cannot be found in the collection corresponding to the requested name or ordinal.
/default2.asp, line 19
第19行如下;
countEmail = CmdCheckEmail("CountEmail")
电子邮件确实存在于表与表只是有以下几列; ReferredEmail和ReferredCode
我想知道是否有人能够解决这个错误?
谢谢。
@Orbman - 我正在使用MSSQL数据库,但是仍然报告使用'CountEmail'或CountEmail时出现同样的错误:( – doubleplusgood 2009-09-24 11:44:27
您正在使用cmd对象不正确,请参阅我的编辑 – RedFilter 2009-09-24 11:48:30
感谢Orbman,我现在得到一个对象:'conn' /default2.asp,第20行错误 – doubleplusgood 2009-09-24 11:53:31