@baburmm
Try the code below, it works
<%@ Language=VBScript %>
<%
'Change HTML header to specify Excel's MIME content type
Response.Buffer = TRUE
Response.ContentType = "application/vnd.ms-excel"
%>
<HTML>
<BODY>
<p>
<%
' Create ADO Connection object
dim myConnection
Dim I
Dim myRecordset
Dim sqlStr
set myConnection = Server.CreateObject("ADODB.Connection")
set myRecordset = Server.CreateObject("ADODB.Recordset")
'Open SQL Server Pubs database...
myConnection.Open "DSN=myweb;uid=abc;password=abc;Database=dbnam e"
'Get a recordset of info from Authors table...
sqlStr = "SELECT * from SUPPLIER"' where empm_empid = 'E0123'"
'sqlstr =Request.QueryString("qry")
'sqlstr=session("excelqry")
'response.write sqlstr
'response.end
I=1
set rsAuthors = myConnection.Execute(sqlStr)
%>
<!-- Our table which will be translated into an Excel spreadsheet -->
<TABLE WIDTH=75% BORDER=1 CELLSPACING=1 CELLPADDING=1>
<!-- server-side loop adding Table entries -->
<% do while not rsAuthors.EOF %>
<% if I=1 then %>
<TR>
<% I=I+1 %>
<% For Each fld In rsAuthors.Fields %>
<TD><%=fld.name %></TD>
<% next %>
</TR>
<% end if %>
<TR>
<% For Each fld In rsAuthors.Fields %>
<TD><%=fld.value %></TD>
<% next %>
</TR>
<% rsAuthors.MoveNext
loop
' Clean up
rsAuthors.Close
set rsAuthors = Nothing
myConnection.Close
set myConnection = Nothing
%>
</TABLE>
</BODY>
</HTML>