CSV Readline
My .csv file has only one column, and is filled with mail addresses.
The purpouse of this aplication is to read the csv mail, check if exists in one database, and return me a eof value. See.Code:
Set objeto = CreateObject("Scripting.FileSystemObject")
archivo = Server.MapPath("pathfile.csv")
set CSV = objeto.OpenTextFile(archivo, forReading )
data=csv.readline()
query = "select * from table where mail = '%" & data & "%'"
recordset.open query, conn
response.write recordset.eof
Never, no matters if the exact mail exist or not, the value of EOF is true. It never finds a comparative in the database. I dont know what can it be.. I suppouse something with variables, like data should be "trimmed", or something else.
And, of course, if I write in the screen both values, they are exactly the same
View Replies
I'm developing an Asp.NET system to take a CSV file uploaded via the web, parse it, and insert the values into an SQL database. My sticking point comes when I try to split() the string returned by readline() on the file.
The following code snippet works for me:
tokens = "one,two,three,four".Split(",")
for each token in tokens
response.write("<td>"+token+"</td>")
next
However, if I take the next line in the CSV, read using StreamReader.ReadLine on the PostedFile.InputStream, I receive "Object reference not set to an instance of an object." which I have narrowed down to be my string holding the line. Further investigation reveals that no other string member functions work on my line (.ToCharArray, .ToString, etc).
I suspect that StreamReader.ReadLine is not correctly returning a string, even though Response.Write(line) displays what I would expect .....
View Replies
View Related