473,323 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

CSV ASP* or PHP solution

6
Hello, I have been trying for as long as I can remember to figure out how to use an HTML form to post the input data to a CSV file.

I am a computer teacher trying to have students complete quizzes etc. and have the data auto sent creating entries in a xls, csv, or (hope to avoid) mdb file.

I read about the whole conversation, created multiple form handers based on your code...big help, made progress but I still cant get it to work.
------------------------

"Microsoft VBScript runtime error '800a003e'

Input past end of file

/upload/csvaspFSO.asp, line 19"
------------------------------
I tried your solution with no joy.
************************************************** *********
FORM HANDLER CODE: (with vitals x'd out)
************************************************** **********
Expand|Select|Wrap|Line Numbers
  1. <%
  2. dim objFSO, objTXT, lines, newRecord, filePath, fieldNames, x
  3.  
  4. filePath = "c:\xxxx\xxxxxxx\xxxxxxx\webroot\upload\csvasp.csv" 'needs absolute path of file
  5. set objFSO = server.createobject("Scripting.FileSystemObject")
  6.  
  7. set objTXT = objFSO.openTextFile(filePath, 1, False) 'opens a text file for
  8. ' reading, true means it will create the file if not already there
  9.  
  10. if trim(objTXT.readall) <> "" then 'file already existed, is not blank
  11.    lines = split(objTXT.readall, vbNewLine) 'lines is now an array, each item is
  12.        ' one line of the file
  13.    fieldNames = split(lines(0), ",") 'now we have a list of the fields in the db.
  14. end if
  15.  
  16. objTXT.close
  17.  
  18. set objTXT = nothing
  19.  
  20. set objTXT = objFSO.openTextFile(filePath, 8, True) 'opens the text file for 
  21.    '  appending %>
  22. <h1>added to the db:</h1>
  23.  
  24. <%
  25. if trim(fieldNames(1)) <> "" then 'there are already field names in the db,
  26.    ' so put the new line in the same order
  27.    for each x in fieldNames
  28.       objTXT.write request.form(x) & ","  'adds each form input to the txtfile
  29.       'in the order of the fields in the db
  30.       response.write request.form(x) & "<br>" & vbNewLine
  31.    next
  32.    objTXT.write vbNewLine
  33. else 'there isn't anything in the textfile yet, so put in the field names first
  34.    for each x in request.form
  35.       objTXT.write x & ","
  36.       response.write x & "<br>" & vbNewLine
  37.    next
  38.    objTXT.write vbNewLine
  39.  
  40.    for each x in request.form
  41.       objTXT.write request.form(x) & ","
  42.       response.write request.form(x) & "<br>" & vbNewLine
  43.    next
  44.    objTXT.write vbNewLine
  45. end if
  46. objTXT.close
  47. %>
School starts in 2 weeks, PLEASE HELP YOU ARE THE COOLEST MOST HELPFUL AND PATIENT PERSON EVER!!!!!!!
Aug 21 '09 #1
8 2453
jhardman
3,406 Expert 2GB
well, I'm not the only person here, but it sure looks like my code, so I think you are talking to me. Thank you for your flattery, and welcome to Bytes.

The error says that it tried to do something with the content of the file, but there wasn't any file left. It seems like the most obvious lines that could cause that error are the two listed here as 11 and 13. Could you check which one is line 19 in your code?

If the problem is what I think it is, you can solve it by saving a blank csv to start, or you can put in a csv with one line filled in - could be a dummy entry or whatever. Try that and see if that solves the problem, if it does, let me know and I will try to revise the code to make a better permanent solution.

Jared
Aug 22 '09 #2
garvus
6
Thanks, sorry I got a little busy.
I tried creating the .csv in excel thinking notepad cudda been the issue. As of right now:
ERROR:
Microsoft VBScript runtime error '800a0046'

Permission denied

/csvaspFSO.asp, line 15
***********************************************
LINE 15:

set objTXT = objFSO.openTextFile(filePath, 1, True) 'opens a text file for
************************************************** ********************************
I don't know why this is so difficult,...could this really be an issue of write permissions? The folder does have write permissions set.....

OK...
Moved the ASP to the same writable dir and got new error:
************************************************** **************
ERROR:
Microsoft VBScript runtime error '800a003e'

Input past end of file

/upload/csvaspFSO.asp, line 19

LINE 19:
lines = split(objTXT.readall, vbNewLine) 'lines is now an array, each item is
************************************************** ********************************

I can't thank you enough for your help, I teach youngsters and using google forms is no good bc I cant make a custom redirect after submission, BUT I also have 430 students to track so this will be invaluable to me for data tracking.

Also, should U rewrite the htm? I just borrowed the one from this page to try and learn...really there will be between 4 - 10 text areas (maybe a radio array or two) but thats it.
http://ps277.org/upload/csvformtester.htm
http://ps277.org/upload/csvaspFSO.asp

Closer to the actual form:
http://ps277.org/ps277/tech/typingindex.htm
Rough and incomplete but you can get the idea....

THANKS ANOTHER BAZILLION!!!!!
Aug 25 '09 #3
garvus
6
JHARDMAN (aka code genious super helper)

OK here goes, I reviewed some conversations and this is where I am at:
second ASP: http://marcmolloy.com/upload/csvaspFSO1.asp
to test different code:

dim x
for each x in request.form
response.write x & ": " & request.form(x) & vbNewLine
next

dim objFSO, objTXT, filePath

filePath = "C:\inetpub\csvFiles\myCSVdb.csv" 'change this to whatever your
'path is
set objFSO = server.createobject("Scripting.FileSystemObject")

set objTXT = objFSO.openTextFile(filePath, 1, True)

response.write "<textarea>" & objTXT.readall & "</textarea>"

ERROR NOW READS:
_q1: 5 comments: 55 _q2: 5 CSVFILEIN: template.txt CSVFILEOUT: results.csv _q3: 5 _q4: 5 _q5: 0 _q6: 1 DONESCREEN: http://whatevertheheck.com _q7: 2 _q8: 3 submit: submit
Microsoft VBScript runtime error '800a004c'

Path not found

/upload/csvaspFSO1.asp, line 13

************************************************** ***********
I think it is taking in the data but not writing it to the csv..... what do ya think?
Aug 25 '09 #4
garvus
6
JAHARDMAN (CODE GENIOUS)
Realized I didnt put MY absolute path, changed it and got this:

_q1: 5 comments: 556 _q2: 5 CSVFILEIN: template.txt CSVFILEOUT: results.csv _q3: 5 _q4: 5 _q5: 0 _q6: 1 DONESCREEN: http://whateverthefuck.com _q7: 2 _q8: 3 submit: submit

*****AND a stretchable box with:
class,name,time,errors,message,6,7,8,9

those are the headings from my csv.
BUT NO INPUT DATA....GETTING CLOSER!!! WOOHOO!!!!
Aug 25 '09 #5
garvus
6
switched back to your other code for koolaid82 about FSO text streaming...
long code about 1/5 the way down... http://bytes.com/topic/asp-classic/a...sv-file-server

----gave me an error:

Microsoft VBScript runtime error '800a003e'

Input past end of file

/upload/csvaspFSO1.asp, line 11

LINE 11:
lines = split(objTXT.readall, vbNewLine) 'lines is now an array, each item is


SORRY bout all the readin but I would like to nail this fast so I want to give you as much info as possible....
Aug 25 '09 #6
jhardman
3,406 Expert 2GB
@garvus
make sure the read/write/modify permissions are set for iusr_<machinename>, that is the user that the script is using.
OK...
Moved the ASP to the same writable dir and got new error:
************************************************** **************
ERROR:
Microsoft VBScript runtime error '800a003e'

Input past end of file

/upload/csvaspFSO.asp, line 19

LINE 19:
lines = split(objTXT.readall, vbNewLine) 'lines is now an array, each item is
************************************************** ********************************
I am fairly certain that this is saying it can't find the file. put the file in place first.
I can't thank you enough for your help, I teach youngsters and using google forms is no good bc I cant make a custom redirect after submission, BUT I also have 430 students to track so this will be invaluable to me for data tracking.

Also, should U rewrite the htm? I just borrowed the one from this page to try and learn...really there will be between 4 - 10 text areas (maybe a radio array or two) but thats it.
http://ps277.org/upload/csvformtester.htm
http://ps277.org/upload/csvaspFSO.asp

Closer to the actual form:
http://ps277.org/ps277/tech/typingindex.htm
Rough and incomplete but you can get the idea....

THANKS ANOTHER BAZILLION!!!!!
I am a firm believer that the HTML is secondary. I always try to get the script working first.

Jared
Aug 25 '09 #7
garvus
6
Sorry, but the write permissions were set to writeable by my host company,they've been fine for a year in the upload folder, that's why I chose it.

iusr_<machinename> Dont know how to do this, but I know that I am able write to that folder. I just checked and the csv file has permissions also.

OK, so "input past end of file" file is in the correct place and proper permissions are set.

For whatever reason it wont ADD the input to the csv !!! AARRRGGGHHH!
Aug 26 '09 #8
jhardman
3,406 Expert 2GB
OK, let's go back to the version that wrote the field headers to the csv file, that is definitely on the right track. Which version of the code was that?

Jared
Sep 1 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: John | last post by:
Dear all, I've got a security question that is so difficult that "maybe" there will be no answer for it. It's regarding protecting asp code. I did write some asp code, that I sell to...
3
by: Mark | last post by:
Ok, I know that .net inherently does not share session data across asp.net projects, but is there any decent work around to this. We already have a big chunk of our application using the asp.net...
8
by: Jon Paul Jones | last post by:
For some time now, I have been looking for a build system for ASP.NET that will merge the file based ease of deployment of classic ASP with the type saftey and prebuilt nature of ASP.NET with...
3
by: epigram | last post by:
I've been creating some toy ASP.NET apps in an effort to understand the technology. I've something odd with regards to project/solution creation. If you create a new asp.net application, it...
10
by: Conan | last post by:
Hi, I am having a problem with .Net / Visual Studio that I can't find the cause of. I have searched newsgroups and the web and find people with similar but different (I think) problems. Here's...
10
by: Amelyan | last post by:
It takes VS 2005 1, 2, and somtimes 3 MINUTES to compile ASP.NET 2.0 website when external DLL is modified. As a matter of fact, when I click 'Build', it looks like VS 2005 hangs for most of that...
8
by: Deepblue | last post by:
I need to develop a webcasting solution. (mostly realtime broadcast) I am considering the apache/php vs iis/asp.net. I am a MSFT guy myself (vc++, vb6, asp.net) but new to multimedia(video...
9
by: Stimp | last post by:
I'm trying to copy an asp.net project onto another computer in order to work on it from there as well. Whatever way I set up the directory in IIS the project cannot be run on the new computer (I...
1
by: sreemati | last post by:
Hi Everyone, I have newly started as a ASP developer. I have been working on some change request and was blogged down with dynamic includes. Eventually I had managed to figure out the problem and...
5
by: JeremyWoertink | last post by:
Hi, I'm new to this whole ASP.NET stuff. I was assigned a project at work to change an application someone else wrote, so I got it all changed on my local machine, then I copied the files over to...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.