Classic ASP why nothing being display on screen?

I have a qns on classic ASP

SQL will return 2 value but when I run on classic ASP page

My output return as
Date Email Sent
Email
Date Email Sent
Email
Anything wrong? What is the correct syntax here?

<% 
'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
%>


Source: sql

1 Comment

  1. Vijay Sutariya

    Hi Jarvis,

    You need to use recordset field reference instead of direct variable.

    Refer below code

    Response.write “”
    Response.Write(“Date ” &Recordset(“OrderH_dtmInitiated”) )
    Response.Write(“Email Sent ” &Recordset(“OrderH_strEmailConfirmationSent”))
    Response.write “”
    Response.Write(“Email ” &Recordset(OrderH_strEmail”))
    Response.write “”

    Let us know if you have any queries

    Regards
    Vijay Sutariya
    09892454096
    India

    Reply

Leave a Reply