473,471 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

2 New Member
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
2 1653
jhardman
3,406 Recognized Expert Specialist
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
chrisf01
2 New Member
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

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

Similar topics

2
by: lawrence | last post by:
I've been bad about documentation so far but I'm going to try to be better. I've mostly worked alone so I'm the only one, so far, who's suffered from my bad habits. But I'd like other programmers...
27
by: C Gillespie | last post by:
Dear All, Hopefully I have a simple problem. Basically, I just want to alter some text with JS. Here is some of my test code: <snip> <script type="text/javascript"> var tmp='a';
11
by: pradeep_TP | last post by:
Hi all, I have a few questions that I have been wanting to ask for long. These are all related to ADO.net and specifically to conenction to database. 1) If I have opened a connection to a...
13
by: John Salerno | last post by:
The code to look at is the try statement in the NumbersValidator class, just a few lines down. Is this a clean way to write it? i.e. is it okay to have all those return statements? Is this a good...
12
by: Sean Davis | last post by:
I am working on a simple script to read from one database (oracle) and write to another (postgresql). I retrieve the data from oracle in chunks and drop the data to postgresql continuously. The...
9
by: andy.z | last post by:
If 2 people try to access the same text file at the same time to write to it - what happens in PHP ? What I mean is - presumably the first will be ok - But what will the second person actually...
12
by: =?Utf-8?B?Smlt?= | last post by:
I have code that reads and parses a text file using a schema.ini file. Works great. When I see the dataGrid it's exactly what I want. Dim CString As String = _...
2
by: cmrhema | last post by:
Hi All , I have with me a server socket program, I am receiving all the clients, but what happens is i have to write it into a file. This consumes time. So we do not have a data loss, but as...
7
by: tshad | last post by:
I have a program in 2005 that is reading a text file removing text and then writing it back out again. It removes lines that start with PRINT. This program has worked fine for months. Now all...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.