Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validation

Status
Not open for further replies.

sweetleaf

Programmer
Jan 16, 2001
439
CA
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, &quot;,&quot;)
pos3b = instr(pos2 - 1, dm, &quot;,&quot;)
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(&quot;comma delimitted file pls&quot;)
END IF
 
First thing I would do is troubleshoot it.

display all the values step by step and you will likely find that you aren't getting what you expect in one of the variables you are filling.

Good luck Steve Davis
hey.you@hahaha.com.au
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top