Forum Moderators: open
Example:
filename - inventory.txt
file-type - text
file-body -
GITN, BeerName, Qty, Price
132983911, Stone IPA 3 Liter, 3, 89.99
564139217, Alesmith Stumblin’ Monk, 13, 13.99
923498723, Dogfish Head World Wide Stout, 128, 8.99
132983911, Budweiser 24-Pack, 241113, 4.29
564139214, Anchor Small Beer, 13, 1.99
923498721, LaConner IPA, 100, 1.79
Does anyone know a way to do this?
Would I be better off saving it to the file system and then parsing the file from there, and then inserting the result into the database?
PLEASE HELP!
' parse the filehandler (fh) data
do while not fh.eof
' grab the field data from the text file
intGTIN = fh("GTIN")
strBeerName = fh("BeerName")
intQty = fh("Qty")
fltPrice = fh("Price")
' build the SQL INSERT statement
strSQL = "INSERT INTO Inventory (GTIN, BeerName, Qty, Price) VALUES (" & inGTIN & ", '" & strBeerName & "', " & inQty & ", " & fltPrice & ")"
' input the file data into the database
dataConn.Execute (strSQL)
fh.movenext
loop
If it was me I would use ":" or "¦" as the delimeter rather than "," as this is fairly common in product descriptions.
Parsing delimited files with the FileSystemObject is simple and effective (check out the VB Split statement if you don't already know it)
If it was my site I would let the client upload via FTP and parse from there (this appears to be the route Google have taken with their Froogle system)
Its also fairly easy to write a scheduled task on an MS server to automatically execute an ASP file.
You just need to add the code execute (or build) SQL.