0

I've got a problem with the following code pasted below, the problem seems to be coming from the openastextstream this carries on from another question:

Set str_text_stream = obj_file.OpenAsTextStream(ForReading, TristateUseDefault) response.Write "<table>" int_j = 0 int_x = 0 Err.number = 0 Do While Not str_text_stream.AtEndOfStream str_po_insert_sql = "INSERT into tbl_purchase_orders (purchase_order_number, purchase_order_vendor_number, purchase_order_vendor_name) " str_po_insert_sql = str_po_insert_sql & " VALUES (" str_line = str_text_stream.readline arr_line = Split(str_line, """,""", -1) if Ubound(arr_line) <> 2 then Response.write "<tr><td>The line " & str_line & " could not be imported.</td></tr>" int_x = 1 else int_y = Instr(arr_line(2), """,") - 1 str_field_0 = Replace(arr_line(0), """", "") str_field_0 = Replace(str_field_0, "'", "''") str_field_1 = Replace(arr_line(1), "'", "''") str_field_2 = Left(arr_line(2), int_y) str_field_2 = Replace(str_field_2, "'", "''") str_po_insert_sql = str_po_insert_sql & "'" & str_field_0 & "', '" & arr_line(1) & "', '" & str_field_2 & "')" rs_po_insert.Open str_po_insert_sql, dbConnection, 3 if Err.number <> 0 then Response.write "<tr><td>The line " & str_po_insert_sql & " was imported.</td></tr>" end if Err.number = 0 int_j = int_j + 1 end if loop 

data from test import:

"4501366934","800002","Clancy Docwra Ltd",04/05/2010 00:00:00 "4501366935","800004","Clancy Docwra Ltd",04/05/2010 00:00:00 "4501366936","800004","Clancy Docwra Ltd",04/05/2010 00:00:00 
4
  • Are you sure that obj_file has a value? Commented Jun 11, 2010 at 12:34
  • Can you also define what you mean by "carries on from another post", post as in HTTP POST? Commented Jun 11, 2010 at 12:48
  • yes the file it is reading from has a value. I've checked the file path and contents of the file. Commented Jun 14, 2010 at 15:29
  • So it is erroring out on this line: Set str_text_stream = obj_file.OpenAsTextStream(ForReading, TristateUseDefault) How are you setting obj_file? Commented Jun 14, 2010 at 16:00

1 Answer 1

1

This error was being caused by

str_file_path = Server.MapPath("/COBRA/upload/PJI3.txt") Server.MapPath 

Was no longer functioning due to a IIS file structure change. Strangely, no error was being thrown even though the openstream was not reading any data. Took me a long time to find this!

Sign up to request clarification or add additional context in comments.

2 Comments

It’s a good hint to check whatever MapPath yields and also its documentation at msdn.microsoft.com/en-us/library/ms524632%28v=vs.90%29.aspx
Why did you add "Server.MapPath" again in the code box? Do you mean "Server.MapPath was no longer functioning due to a IIS file structure change..." ? In which case that makes sense, albeit what does IIS file structure change mean? Just a simple file change or the entire path was changed?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.