崩溃fname.WriteLine(x)(asp经典)

时间:2015-08-12 12:50:33

标签: asp-classic

filename = filename&random_number1&random_number2
rootDir = Server.MapPath("\Temporary Files\"&filename&".txt")

    dim fs,fname
    set fs=Server.CreateObject("Scripting.FileSystemObject")
    set fname=fs.CreateTextFile(rootDir,true,false)
    set rs = server.CreateObject("ADODB.recordset")
    sqlString=str

    rs.Open sqlString, conn, 3,1
        if rs.recordcount>0 then
            countfields   = rs.Fields.Count 
            rsrecordcount = rs.recordcount

               fname.WriteLine("")
                for i=1 to rsrecordcount 
                    laststring ="" 
                        for k=0 to countfields-1

                            if k=0 then
                                laststring =trim(rs(k)) // Writing into laststring all the values
                            else
                                if rs.Fields(k).Name = "FactoryPriceUSD" then

                                    Set rsrate = server.CreateObject("ADODB.recordset")
                                    sqlstring="SELECT [Convert] FROM tblCurrenciesLog WHERE ([Date] = CONVERT(datetime,'"&rs(2)&"',103) AND  FromCurrencyID=2 AND ToCurrencyID=1)"
                                    rsrate.open sqlstring,conn,3,1

                                    if rsrate.RecordCount>0 then
                                        ratestr = rsrate(0)
                                    else
                                        ratestr = "0"
                                    end if

                                    laststring =laststring&delimiter&trim(rs(k))&delimiter&ratestr
                                elseif rs.Fields(k).Name = "DeductPaymentTerms" then
                                    if cdbl(rs(k))>0 then 
                                        laststring =laststring&delimiter&"True"
                                     else
                                        laststring =laststring&delimiter&"False"
                                     end if
                                elseif rs.Fields(k).Name = "DeductAdditional" then
                                    if cdbl(rs(k))>0 then 
                                        laststring =laststring&delimiter&"True"
                                     else
                                        laststring =laststring&delimiter&"False"
                                     end if
                                else

                                    laststring =laststring&delimiter&trim(rs(k)) // Writing into laststring all the values
                                end if
                            end if
                        next
                     x = laststring&Chr(10)
                    fname.WriteLine(x) //crashed here  
                rs.movenext
                next


hello my codes crashed in : `fname.WriteLine(x)`

because x include unknown `unicode` like '`Saarbrücken`' 

how to fix that ?

如果完整代码:

{{1}}

也许应该改变文字的unicode?

我的代码在fname.WriteLine(x)中崩溃了为什么?

1 个答案:

答案 0 :(得分:0)

我通过将区域从“非unicode”更改为英语(美国)来解决我的问题。