By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,658 Members | 1,538 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,658 IT Pros & Developers. It's quick & easy.

write to text file and database at the same time inside for statement?

P: 2
I am trying to write to a text file and the database at the same time. I have a For statement that loops through all the repeated fields in my form and writes it to a text file. That part works 100% without a problem.

My problem is that I also want to write to the SQL database at the same time and anytime I put the sql stored procedure inside the same For statement I get a http 500 error. Do I need to do this outside of the current For statement or am I doing something incorrect?

Thanks!

Expand|Select|Wrap|Line Numbers
  1. Dim fso, act
  2. Dim sCon, strSQL
  3. Dim rsProcess
  4. set fso = createobject("scripting.filesystemobject")
  5. Set act = fso.CreateTextFile(strServerpath&"new_"&strPart_number&strOutput_ext, true)
  6. act.WriteLine "Date:,"&Date
  7. act.WriteLine "Time:,"&Time
  8. act.WriteLine "Carline Code:,"&strcarline
  9. act.Writeline "Filter B:,"&strsub_system
  10. act.writeline "GO Version:,"&intprod_ver
  11. act.writeline "Hand:,"&strhandiness
  12. act.writeline "LD Version:,1"
  13. act.writeline "EI Level:,"&strei_level
  14. act.writeline "DC Version:,"
  15. act.writeline "Part Name:,"&strpart_name
  16. act.writeline "Part Number:,"&strPart_number
  17. act.writeline "Plant Code:,"&strplant_code
  18. act.writeline "Sym Opp:,"&strsym_opp
  19. act.writeline "WLRR:,"&intwlrr
  20. act.writeline "LRR#:,"&intlrr
  21. act.writeline "Concern:,"&strconcern
  22. act.writeline "Operator:,"&strOperator
  23. act.writeline "Type:,Component"
  24. act.writeline
  25. act.writeline "Label,X Value, Y Value, Z Value, I Value, J Value, K Value, Size 1, Size 2, Flag #, Sub Type, Subscript, selection set 1, PCA Note, Open Issue Note, Other Notes"
  26. For intV=1 to total_points
  27. strLabel = request.Form ("label"&intv&"")
  28. intX_value = request.Form ("x_value"&intv&"")
  29. intY_value = request.Form ("y_value"&intv&"")
  30. intZ_value = request.Form ("z_value"&intv&"")
  31. intI_value = request.Form ("i_value"&intv&"")
  32. intJ_value = request.Form ("j_value"&intv&"")
  33. intK_value = request.Form ("k_value"&intv&"")
  34. intSize_1 = request.Form ("size_1"&intv&"")
  35. intSize_2 = request.Form ("size_2"&intv&"")
  36. strFlag_num = request.Form ("flag_num"&intv&"")
  37. strSub_type = request.Form ("sub_type"&intv&"")
  38. strSubscript = UCASE(request.Form ("subscript"&intv&""))
  39. strSelection_set = request.Form ("selection_set"&intv&"")
  40. strPca_note = request.Form ("pca_note"&intv&"")
  41. strOi_note = request.Form ("oi_note"&intv&"")
  42. strOther_note = request.Form ("other_note"&intv&"")
  43.  
  44. act.writeline strLabel&","&intX_value&","&intY_value&","&intZ_value&","&intI_value&","&intJ_value&","&intK_value&","&intSize_1&","&intSize_2&","&strFlag_num&","&strSub_type&","&strSubscript&","&strSelection_set&","&strPca_note&","&strOi_note&","&strOther_note
  45.  
  46. strSQL = "prInsertCompInfo '" & strLabel & "," & intX_Value & "," & intY_Value & "," & intz_value & "," & inti_value & "," & intj_value & "," & intk_value & "," & intSize_1 & "," & intSize_2 & "," & strFlag_Num & "," & strSub_type & "," & strSubscript & "," & strSelection_set & "," & strPca_Note & "," & strOI_note & "," & strOther_Note & "," & null & "'"
  47. Set rsProcess = con.execute(strSQL)
  48.  
  49. Next
  50.  
Jul 13 '07 #1
Share this Question
Share on Google+
2 Replies


jhardman
Expert 2.5K+
P: 3,405
I don't know of any requirement, I've seen people write to two different dbs at the same time and I would think that is harder, but personally I would wait until the one is finished before starting the other. Specifically, I would do the db first, but maybe at the same time construct a very long string variable containing everything I want to add to the text file, then when I've finished with the db, write the text file all at once. Let me know if this helps.

Jared
Jul 13 '07 #2

P: 2
Ended up not being anything with my statements or order of them. Was between the stored procedured and what I was trying to pass through it.

I love having deadlines that make you rush through stuff without looking at the simple things.

Thanks for the help though.
Jul 14 '07 #3

Post your reply

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