Hello people,
I managed to figure it out :o)
Sorry to have troubled you.
Minty
"Mintyman" <mintyman@ntlworld.com> wrote in message
news:fn75lo$noi$1@forums.macromedia.com...
> HI,
>
> I'm trying to create a way to export database records to
Excel. So far, I
> have managed to get it working for one row in the
database table. However,
> I can't work out how to make it loop through all the
rows and output the
> entire table.
>
> I'm using DM8 / ASP/VBScript
>
> Here is what I have so far :
>
> <%
> Dim Excel
> Dim Excel_cmd
> Dim Excel_numRows
>
> Set Excel_cmd = Server.CreateObject ("ADODB.Command")
> Excel_cmd.ActiveConnection = MM_MyDatabase_STRING
> Excel_cmd.CommandText = "SELECT * FROM customers ORDER
BY id ASC"
> Excel_cmd.Prepared = true
>
> Set Excel = Excel_cmd.Execute
> Excel_numRows = 0
>
> ''// Set the name of the file that you are going to
output
> FileName = "MySpreadsheet.xls"
>
> ''// Build up a regular HTML table (this translates into
the rows and
> cells in excel)
> sData =
"<table><tr><th>Name</th><th>Password</th></tr>"
>
> sData = sData & "<tr><td>" &
(Excel.Fields.Item("FirstName").Value) &
> "</td><td>" &
(Excel.Fields.Item("password").Value) &
"</td></tr>"
>
> sData = sData & "</table>"
>
> ''// Write out the table
> response.write sData
>
> ''// Set the Header info
> Response.ContentType = "application/vnd.ms-excel"
> Response.AddHeader "content-disposition","attachment;
filename=" &
> FileName
>
> Excel.Close()
> Set Excel = Nothing
> %>
>
> Can anyone show me what I need to do to get it to look
through every
> record?
>
> Thanks!
>
>