Sql 为什么屏幕上什么都不显示?

Sql 为什么屏幕上什么都不显示?,sql,asp-classic,Sql,Asp Classic,SQL将返回2值,但当我在经典ASP页面上运行时 我的输出返回为 发送电子邮件的日期 电子邮件 发送电子邮件的日期 电子邮件 有什么问题吗?这里的正确语法是什么 <% 'declare the variables Dim Connection Dim ConnString Dim Recordset Dim SQL 'define the connection string, specify database driver ConnString="Driver={SQL Server

SQL将返回2值,但当我在经典ASP页面上运行时

我的输出返回为 发送电子邮件的日期 电子邮件 发送电子邮件的日期 电子邮件 有什么问题吗?这里的正确语法是什么

<% 
'declare the variables 
Dim Connection
Dim ConnString
Dim Recordset
Dim SQL

'define the connection string, specify database driver
ConnString="Driver={SQL Server};Server=10.0.0.96;Database=VISTAIT;Uid=sa;Pwd=CqLxxxx1;"

'declare the SQL statement that will query the database
SQL = "SELECT OrderH_dtmInitiated,OrderH_strEmailConfirmationSent  ,OrderH_strEmail FROM tblOrderHistory WHERE  OrderH_strEmailConfirmationSent is NULL And OrderH_dtmInitiated >= (SELECT  DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()-1))) ORDER by OrderH_dtmInitiated" 

'create an instance of the ADO connection and recordset objects
Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")

'Open the connection to the database
Connection.Open ConnString

'Open the recordset object executing the SQL statement and return records 
Recordset.Open SQL,Connection

'first of all determine whether there are any records 
If Recordset.EOF Then 
Response.Write("No records returned.") 
Else 
'if there are records then loop through the fields 
Do While NOT Recordset.Eof   

Response.write "<br>"   
Response.Write("Date " &OrderH_dtmInitiated )
Response.Write("Email Sent " &OrderH_strEmailConfirmationSent)
Response.write "<br>"   
Response.Write("Email " &OrderH_strEmail)
Response.write "<br>"    
Recordset.MoveNext     
Loop
End If

'close the connection and recordset objects to free up resources
Recordset.Close
Set Recordset=nothing
Connection.Close
Set Connection=nothing
%>

假设记录集有2条记录

然后,循环中的response.writes不应写入未声明的ASP变量,而应写入记录集对象的元素。正确的编码应该是

Response.Write("Date " & Recordset("OrderH_dtmInitiated") )
Response.Write("Email Sent " & Recordset("OrderH_strEmailConfirmationSent"))
Response.write "<br>"   
Response.Write("Email " & Recordset("OrderH_strEmail"))
Response.Write(“日期”和记录集(“OrderH\u dtmInitiated”))
回复。写入(“已发送电子邮件”和记录集(“OrderH_StremailConfirmationment”))
Response.write“
” 回复。写(“电子邮件”和记录集(“OrderH_strEmail”))
如果OrderH\u stremailconfirmationment值为null,我注意到它不会显示任何值…我们应该如何在asp对象上显示null?要么编辑视图,使其永远不具有null值,要么创建一个小循环,以接受数组中的记录集值,使用
TRIM(rs(|“value”)&>
。空格将泛型类型强制为字符串,修剪将再次删除空格。