2015-12-11 111 views
-1

我有這個asp腳本,但我得到一個錯誤: 預計結束....我做錯了什麼?asp閱讀csv我做錯了什麼

我嘗試一切,編輯該文件,但我仍然得到這個錯誤

我已經把客戶的文件在同一目錄下,

有人可以幫我請,我並不擅長這個

<%Option Explicit%> 
<html> 
<head> 
<title>car track Tutorial</title> 
</head> 
<body> 
<% 
Dim objFSO,oInStream,sRows,arrRows 
Dim sFileName 

sFileName = "customer.csv" 

'*** Create Object ***' 
Set objFSO = CreateObject("Scripting.FileSystemObject") 

'*** Check Exist Files ***' 
If Not objFSO.FileExists(Server.MapPath(sFileName)) Then 
    Response.write("File not found.") 
Else 

'*** Open Files ***' 
Set oInStream = objFSO.OpenTextFile(Server.MapPath(sFileName),1,False) 

%> 
<table width="600" border="1"> 
    <tr> 
    <th width="91"> <div align="center">CustomerID </div></th> 
    <th width="98"> <div align="center">Name </div></th> 
    <th width="198"> <div align="center">Email </div></th> 
    <th width="97"> <div align="center">CountryCode </div></th> 
    <th width="59"> <div align="center">Budget </div></th> 
    <th width="71"> <div align="center">Used </div></th> 
    </tr> 
<% 
Do Until oInStream.AtEndOfStream 
sRows = oInStream.readLine 
arrRows = Split(sRows,",") 
%> 
    <tr> 
    <td><div align="center"><%=arrRows(0)%></div></td> 
    <td><%=arrRows(1)%></td> 
    <td><%=arrRows(2)%></td> 
    <td><div align="center"><%=arrRows(3)%></div></td> 
    <td align="right"><%=FormatNumber(arrRows(4),2)%></td> 
    <td align="right"><%=FormatNumber(arrRows(5),2)%></td> 
    </tr> 
<% 
Loop 

oInStream.Close() 
Set oInStream = Nothing 
end if 
%> 
</table> 
</body> 
</html> 

這是錯誤

Script error: Expected 'End'

Dim objFSO,oInStream,sRows,arrRows 
Dim sFileName 

sFileName = "customer.csv" 

'*** Create Object ***' 
Set objFSO = CreateObject("Scripting.FileSystemObject") 

'*** Check Exist Files ***' 
If Not objFSO.FileExists(Server.MapPath(sFileName)) Then 
    Response.write("File not found.") 
Else 

'*** Open Files ***' 
Set oInStream = objFSO.OpenTextFile(Server.MapPath(sFileName),1,False) 

我改變了它,但現在它只讀取第4行中只有我的csv文件...

+0

可以請你發佈完整的錯誤? – Alex

+0

我編輯了帖子,錯誤在帖子的末尾 – user3785784

回答

0

你缺少一個End If聲明:

'*** Check Exist Files ***' 
If Not objFSO.FileExists(Server.MapPath(sFileName)) Then 
    Response.write("File not found.") 
Else 
    '*** Open Files ***' 
    Set oInStream = objFSO.OpenTextFile(Server.MapPath(sFileName),1,False) 
End If 
+0

您也在'Do Until'循環結尾處缺少'Loop'語句。 –

+0

循環語句是在那裏,但我編輯它,我再次得到一個錯誤,它沒有找到我的文件 – user3785784

+0

我編輯了你說的事情,但它只讀取我的第四行在我的CSV文件...現在怎麼了?它需要讀取我的整個csv文件:P – user3785784