473,699 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
+ 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 1660
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
3053
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 to have an easier time understanding what I do. Therefore this weekend I'm going to spend 3 days just writing comments. Before I do it, I thought I'd ask other programmers what information they find useful. Below is a typical class I've...
27
2235
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
2432
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 database through Connection.open() method, and I do not use Connection.close() method, will garbage collector collect the connection object just because i am not using it any more. 2) I am using a dataset, in which i make some modifications to the...
13
1746
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 use of try? Etc. Thanks. ---------------------------- import wx
12
5461
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 author of one of the python database clients mentioned that using one thread to retrieve the data from the oracle database and another to insert the data into postgresql with something like a pipe between the two threads might make sense, keeping...
9
6939
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 see in his browser? And what will php do about it if not specifically programmed to deal with it ie whats the default behaviour?
12
2094
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 = _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\;" & _ "Extended Properties=""text;HDR=No;""" Dim TConnect As New System.Data.OleDb.OleDbConnection(CString)
2
1683
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 the time taken to write into the log file increases, some of the data does not get written. This is the code //ONLY SHOBA
7
1638
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 of a sudden, it is reading a straight text file and adding a null after each character it reads in. Why is that? The original file doesn't have nulls in them. The code is: ******************************************** using System;
0
8685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8613
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9172
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8880
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6532
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4374
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.