我有这个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