我有這個Asp Classic 3.0代碼的問題。Asp經典3.0循環和movenext
我需要發送電子郵件時中的SQL查詢的數據庫表中找到與記錄:
SQL = " SELECT * FROM doTable Where div = 1; "
我試圖此ASP代碼:
SQL = " SELECT * FROM doTable Where div = 1; "
Set Rec = createObject("ADODB.Recordset")
Rec.open SQL, cn
If not Rec.eof then
msg = msg & VBcrlf & "<br />Records founds!<br />"
Do while not Rec.eof
msg = msg & VBcrlf & "ID record: " & Rec("Id") & ""
msg = ""
Rec.moveNext()
Loop
Else
msg = msg & VBcrlf & "<br />No records!<br />"
End If
Rec.close()
set Rec = nothing
cn.close()
set cn = nothing
問題是這部分代碼:
msg = ""
如果我發現記錄和味精= 「」存在於代碼中,msg的輸出爲空;如果味精=「」沒有出現在代碼的輸出是:
Records founds!
ID record: 32
Records founds!
ID record: 61
Records founds!
ID record: 77
爲什麼我不能得到這個輸出?
Records founds!
ID record: 32
ID record: 61
ID record: 77
你能幫幫我嗎? 感謝您在高級 -
編輯
With objMessage
.From = RS("Email_from")
.To = RS("Email_to")
.Subject = "Alert div"
.HtmlBody = msg
.Fields("urn:schemas:httpmail:importance").Value = 2
.Fields("urn:schemas:mailheader:X-MSMail-Priority") = 6
.Fields.Update()
on error resume next
.Send
if Err.Number <> 0 then
response.Write "Email send failed # : " & Err.Number & " - " & Err.Description & ".<br />"&vbcrlf
end if
End With
非常感謝你! –
以這種方式字符串「Records founds!」總是出現,如果沒有記錄。 –
@FabioPellerito - 我不這麼認爲。 'msg =「
沒有記錄!
如果記錄集爲空,則應覆蓋」找到記錄「。 – John