views:

97

answers:

1

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
A: 

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!

jeff