
June 29th, 2004, 11:41 PM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Array Problems
Hi everyone, I seem to have a problem with my code. I get the following error when I try to run my script (reads from an 11 column CSV file):
Microsoft VBScript runtime (0x800A0009)
Subscript out of range: '[number: 155]'
/csvtest.asp, line 40
Here is my code:
Code:
<%
csv_to_read="CSVTest.csv"
set fso = createobject("scripting.filesystemobject")
set act = fso.opentextfile(server.mappath(csv_to_read))
'imported_text = act.readline
imported_text="Sku,Description,Finished,Category1,Category2,Categ ory3,Royalty,New,NFrom,NTo,UPC"
imported_text = replace(imported_text,chr(13),",")
imported_text = replace(imported_text,chr(34),"")
split_text=split(imported_text,",")
num_imported=ubound(split_text)+1
total_imported_text = act.readall
total_imported_text = replace(total_imported_text,chr(13),",")
total_imported_text = replace(total_imported_text,chr(34),"")
total_split_text=split(total_imported_text,",")
total_num_imported=ubound(total_split_text)
function formattext(text)
formattext = replace(text,"**",",")
end function
%>
<%
dim count
count=0
for tablea = 0 to (total_num_imported/ (num_imported)-1)
%>
<%
for table = 0 to num_imported -1
%>
Insert into TableName(<%=imported_text%>) Values(<%=formattext(total_split_text(count))%>,<%=formattext(total_split_text(count+1))%>,<%=formattext(total_split_text(count+2))%>,<%=formattext(total_split_text(count+3))%>,<%=formattext(total_split_text(count+4))%>,<%=formattext(total_split_text(count+5))%>,<%=formattext(total_split_text(count+6))%>,<%=formattext(total_split_text(count+7))%>,<%=formattext(total_split_text(count+8))%>,<%=formattext(total_split_text(count+9))%>,<%=formattext(total_split_text(count+10))%>)<br><br>
<%
count=count+11
next
%>
<% next%>
Thanks for the help!
|