ASP错误424需要对象

时间:2010-06-11 11:11:00

标签: sql sql-server asp-classic vbscript

下面粘贴的代码我遇到了问题,问题似乎来自另一个问题的openastextstream:

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

来自测试导入的数据:

"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

1 个答案:

答案 0 :(得分:1)

此错误是由

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

Server.MapPath

由于IIS文件结构更改而不再运行。奇怪的是,即使开放流没有读取任何数据,也没有抛出任何错误。花了很长时间才找到这个!