|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 :-) |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > What is a CSV file and how to write to it? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|