Quote:
Originally posted by Dahquim
Hello.
I can program quite well in ASP/ASP.net, but was wanting to ask a question regarding something i need to do.
Each moneth we produce a file for a customer, e.g. 123001_33.csv. and i want a ASP/ASP.net page that will load this file into a SQL server database, using the first 6 characters of the file as the userID.
Does anyone have any hints, ideas, or have done this before and could let me have the code.
Thanks a lot
Dahquim
|
First, open the file. Pull off the name. Use the Mid function to grab the first 6 characters..
Now, since a CSV file is just text, you can take the contents of the entire file after reading it into a variable, and use the Split function to split it by vbcrlf.
This will create an array that holds each line in a different space.
Loop through that array and split each value by a comma (this will get you every value). This will create yet another array of values. Loop through that array and generate your SQL statement.