我有一個經典的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