PURPOSE:
insert values of a chosen csv file into an oracle database.
PROBLEM:
while i can provide back end integrity checking, i cannot scan each individual line "read" for commas. for example , when i try adding an if-then-else inside my loop to check if the "line read" contains any commas, the statement is totally ignored - why is that?
THE CODE:
dim fs,fileName,data,ts
bb = Request.Form("f2"
fileName = bb
set ts = server.CreateObject("Scripting.FileSystemObject"
set fs = ts.OpenTextFile(fileName,ForReading)
fs.SkipLine()
do while(not fs.atEndOfStream)
dm = fs.readLine()
lm = len(dm)
pos1 = instr(1,dm,",",0)
dm1 = left(dm,pos1 -1)
pos2 = instr(pos1 - 1, dm, ","
'the problem code
'if first 2 commas exist
IF pos1<>0 or pos2<>0 THEN
pos3 = instr(pos2 + 1, dm, ","
pos3b = instr(pos2 - 1, dm, ","
dm2 = mid(dm,pos2 + 1,pos3b)
pos4 = lm - pos3
dm3 = right(dm,pos4)
'db updates/inserts etc..
ELSE 'if first 2 commas don't exist
response.write("comma delimitted file pls"
END IF
insert values of a chosen csv file into an oracle database.
PROBLEM:
while i can provide back end integrity checking, i cannot scan each individual line "read" for commas. for example , when i try adding an if-then-else inside my loop to check if the "line read" contains any commas, the statement is totally ignored - why is that?
THE CODE:
dim fs,fileName,data,ts
bb = Request.Form("f2"
fileName = bb
set ts = server.CreateObject("Scripting.FileSystemObject"
set fs = ts.OpenTextFile(fileName,ForReading)
fs.SkipLine()
do while(not fs.atEndOfStream)
dm = fs.readLine()
lm = len(dm)
pos1 = instr(1,dm,",",0)
dm1 = left(dm,pos1 -1)
pos2 = instr(pos1 - 1, dm, ","
'the problem code
'if first 2 commas exist
IF pos1<>0 or pos2<>0 THEN
pos3 = instr(pos2 + 1, dm, ","
pos3b = instr(pos2 - 1, dm, ","
dm2 = mid(dm,pos2 + 1,pos3b)
pos4 = lm - pos3
dm3 = right(dm,pos4)
'db updates/inserts etc..
ELSE 'if first 2 commas don't exist
response.write("comma delimitted file pls"
END IF