I will pretend that you have data as such:
CustID Firstname Lastname Address City State ZIP
1 Bo Brady 1 Street Somewhere XX 10001
2 Hope Brady 1 Street Somewhere XX 10001
3 Jack Deveraux 2 Road Somewhere XX 10002
4 Jennifer Deveraux 2 Road Somewhere XX 10002
5 Abe Carver 3 Ave. Somewhere XX 10003
6 Lexie Carver 3 Ave. Somewhere XX 10003
7 Tony Dimera 4 Lane Somewhere XX 10004
8 Rex Dimera 5 Way Somewhere XX 10005
9 Cassie Dimera 4 Lane Somewhere XX 10004
10 Greta Von Amberg 6 Swamp Somewhere XX 10006
So, like, you want a bunch of files like:
10001.csv, 10002.csv, etc.? Maybe something like this:
<object runat="server" progid="Scripting.FileSystemObject"
id="oFSO"></object>
<%
Dim oADO, oRS
Dim sOutput
Dim aZIPs, i, sZIP
Const OUTPUT_PATH = "D:\Path\"
sSQL = "SELECT DISTINCT(ZIP) FROM Customers"
Set oADO = Server.CreateObject("ADODB.Connection")
oADO.Open YourConnectionString
Set oRS = oADO.Execute(sSQL)
aZIPs = oRS.GetRows()
oRS.Close : Set oRS = Nothing
For i = 0 To UBound(aZIPs, 2)
sZIP = aZIPs(0, i)
sSQL = "SELECT CustID,Firstname,Lastname,Address,City,State,ZIP FROM
Customers WHERE ZIP='" & sZIP & "'"
Set oRS = oADO.Execute(sSQL)
sOutput = oRS.GetString(,,",",vbCrLf)
oRS.Close : Set oRS = Nothing
oFSO.CreateTextFile(OUTPUT_PATH & sZIP & ".csv", True).Write sOutput
Response.Write "<a href=""" & sZIP & ".csv"">Click here to download CSV
for ZIP code " & sZIP & "</a><br>"
Next
oADO.Close : Set oADO = Nothing
%>
What that'll do is get all the zips, then loop through them all, query all
the data for each zip, and write a CSV from each resultset.
Ray at home
"atse" <> wrote in message
news:n8pfb.207524$ able.rogers.com...
> Thanks Ray. I remember you have given me great helps before. Yes, I really
> want to export a csv file.
> I have big csv files containing customers' contact info. I want to export
> them by zip code and type to respective csv files. What is the simplest
way
> to do that? Thanks again.
>
> Atse
>
>
> "Ray at <%=sLocation%>" <myfirstname at lane 34 . komm> wrote in message
> news:...
> > There are a couple of things you can do.
> >
> > 1. Build your data in a table and add this to the top of your page:
> > <% Response.ContentType = "application/vnd.ms-excel" %>
> >
> >
> > 2. Build yourself a comma delimited string and save the string to a
file
> > with a .csv file and link to it.
> >
> > 3. Use Office Web Components:
> > http://office.microsoft.com/downloads/2002/owc10.aspx. Before you'd go
> that
> > route, read here though. http://support.microsoft.com/?id=317316
> >
> > If you need more details on 1 or 2, post back with a sample of your data
> > querying and what not.
> >
> > Ray at home
> >
> >
> > "atse" <> wrote in message
> > news:7Vnfb.206907$. cable.rogers.com...
> > > Hi experts,
> > >
> > > I retrieve data from the database and display on ASP, then I export
> these
> > > data to a file, like Excel (the best) or text file. Is it possible? I
> > think
> > > it is possible, but how can I do that? Thanks for any help.
> > >
> > > Atse
> > >
> > >
> >
> >
>
>