ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old September 20th, 2003, 06:53 AM
leeolive leeolive is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: London
Posts: 43 leeolive User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
What is a CSV file and how to write to it?

Hi

I am still new to ASP. I have created a single form. I retrieve the data from the form and place it in variables and then submit the data to an access database.

I now also need to, at the same time, write to a CSV file. Could anyone tell me what this is and how I do this in relation to my present code.

Here's my code which submits to the database. I retrieve a lot more data, but have cut it down to simplify. Also, I may want to only write some of the data retrieved from the form - not all.

Set cndb = server.CreateObject("adodb.connection")
Set cmdaddtodatabase = server.CreateObject("adodb.command")

cndb.CommandTimeout = 15
cndb.CursorLocation = adUseServer
'cndb.ConnectionString = "DSN=cXX" 'this is for local
cndb.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=d:\webs/xxxxxxx/db/1CM_S2P.mdb"
on error resume next
cndb.open

if err <> 0 then
response.write "Error connecting to the database"
response.end
end if

With cmdaddtodatabase
.CommandTimeout = 15
set .ActiveConnection = cndb
.CommandType = adCmdText
.CommandText = "INSERT INTO S2P_Applicant_Details (Title, FirstName) VALUES ('"&strTitle&"','"&strFirstName&"')"
.Parameters.Append(.CreateParameter ("pTitle", adVarChar,adParamInput,50, strTitle))
.Parameters.Append(.CreateParameter ("pFirstName", adVarChar,adParamInput,50, strFirstName))

on error resume next
.Execute

if err.number <> 0 then
Response.write err.description
Response.End
end if
End with

%>

Really appreciate this.
Thanks
Lee

Reply With Quote
  #2  
Old September 20th, 2003, 07:00 AM
Wingman Wingman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Bavaria, Germany
Posts: 140 Wingman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 40 m 41 sec
Reputation Power: 6
CSV means "character seperated values", it's just a flat text file with each column seperated by a specific char (usually "," or ";") and each row seperated by a line break.

Example:
Code:
  Row1Column1,Row1Column2,Row1Column3
  Row2Column1,Row2Column2,Row2Column3
  Row3Column1,Row3Column2,Row3Column3

... and so on...

So if you need to create a .csv file, just open a text file and write the above format. That's it :-)

Reply With Quote
  #3  
Old September 20th, 2003, 07:25 AM
leeolive leeolive is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: London
Posts: 43 leeolive User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Thanks, Wingman

Still a tad confused.

Hope I can explain this better. I have a form on a website, which will users will complete. When user submits the form, my code(see previous message) executes and submits data to the access database.

The company who then requires certain fields from this data *once a week*, needs this in CSV file format.

So, I have this data sitting in my database online and either I must write the data (for that one week) to a CSV file or they must be able to do it. Who should do it and how should it be done?

How will my asp code (see previous message) know when and how to write to the CSV file? Surely I should add some code to my asp code so that when it submits the data to the database, it submits the values to the CSV file? Or, does the writing to the CSV file not happen when the data is submitted to the database?

If the data needs to be written to a CSV file once a week, then how does this happen and who does it and whereabouts does it happen? Where should a command be run and and what command should be run to 'write it'.

Thanks for your help.
Lee

Reply With Quote
  #4  
Old September 20th, 2003, 09:33 AM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
Well you still haven't given us enough information. Will this be a report one week from the day you request it? One week from the most recent Saturday? The future Saturday?

you have a choice, you can make the people that want the csv do it or you can write a batch job. Here's an example of doing this

http://www.aspalliance.com/aspguru/...e=Art&ArtID=885

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > What is a CSV file and how to write to it?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway