By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,413 Members | 1,594 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,413 IT Pros & Developers. It's quick & easy.

Export datas to a Excel file using query without openrowset method

P: 12
Hi all,
Can any one tell me,
Export datas to a Excel file using query without openrowset method

is there any other methods are posible

for creating an Excel file to export it

Nov 24 '09 #1
Share this Question
Share on Google+
1 Reply

P: 2
Try the code below, it works

<%@ Language=VBScript %>
'Change HTML header to specify Excel's MIME content type
Response.Buffer = TRUE
Response.ContentType = "application/"

' 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")

'response.write sqlstr
set rsAuthors = myConnection.Execute(sqlStr)

<!-- Our table which will be translated into an Excel spreadsheet -->
<!-- server-side loop adding Table entries -->
<% do while not rsAuthors.EOF %>

<% if I=1 then %>
<% I=I+1 %>
<% For Each fld In rsAuthors.Fields %>
<TD>< %></TD>
<% next %>
<% end if %>


<% For Each fld In rsAuthors.Fields %>
<TD><%=fld.value %></TD>
<% next %>
<% rsAuthors.MoveNext
' Clean up
set rsAuthors = Nothing
set myConnection = Nothing
Nov 24 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.