Great! Ray.
You know what I want!! Ok, what if retrieve from a .csv (e.g. customer.csv)
file, instead of the SQL db?
Further questions are:
1. I don't know how many groups of Zip (your example has group10001, group
10002..group 10006. totally 6 groups), and I want to export 6 files, like
10001.csv; ... 10006.csv which means the number of output file .csv would be
a variable.
2. If there is no field name in a .csv file but column/comma/table or A, B,
C...X in an Excel file, how can I select them?
3. Actually I have another field name "language" (eng/fre), I want them to
be exported to files eng_10001.csv, eng_10002.csv, fre_10001.csv,
fre_10003.csv. Is it possible for me to do that. Of course, I am sure you
can.
Thanks again!
Cheers,
Atse
"Ray at <%=sLocation%>" <myfirstname at lane 34 . komm> wrote in message
news:%23%23Mgq1hiDHA.4024@TK2MSFTNGP11.phx.gbl...[color=blue]
> 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[/color]
CSV[color=blue]
> 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" <dunggaze@yahoo.com> wrote in message
> news:n8pfb.207524$Lnr1.50742@news01.bloor.is.net.c able.rogers.com...[color=green]
> > Thanks Ray. I remember you have given me great helps before. Yes, I[/color][/color]
really[color=blue][color=green]
> > want to export a csv file.
> > I have big csv files containing customers' contact info. I want to[/color][/color]
export[color=blue][color=green]
> > them by zip code and type to respective csv files. What is the simplest[/color]
> way[color=green]
> > to do that? Thanks again.
> >
> > Atse
> >
> >
> > "Ray at <%=sLocation%>" <myfirstname at lane 34 . komm> wrote in message
> > news:O6n1R2giDHA.1048@TK2MSFTNGP11.phx.gbl...[color=darkred]
> > > 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[/color][/color]
> file[color=green][color=darkred]
> > > with a .csv file and link to it.
> > >
> > > 3. Use Office Web Components:
> > >
http://office.microsoft.com/downloads/2002/owc10.aspx. Before you'd[/color][/color][/color]
go[color=blue][color=green]
> > that[color=darkred]
> > > 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[/color][/color][/color]
data[color=blue][color=green][color=darkred]
> > > querying and what not.
> > >
> > > Ray at home
> > >
> > >
> > > "atse" <dunggaze@yahoo.com> wrote in message
> > > news:7Vnfb.206907$Lnr1.168685@news01.bloor.is.net. cable.rogers.com...
> > > > Hi experts,
> > > >
> > > > I retrieve data from the database and display on ASP, then I export[/color]
> > these[color=darkred]
> > > > data to a file, like Excel (the best) or text file. Is it possible?[/color][/color][/color]
I[color=blue][color=green][color=darkred]
> > > think
> > > > it is possible, but how can I do that? Thanks for any help.
> > > >
> > > > Atse
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]