Forum Moderators: open

Message Too Old, No Replies

Upload txt File To Database With Fields?

Bulk inventory updates done easily?

         

ratebeer

11:03 pm on Jan 8, 2005 (gmt 0)

10+ Year Member



I'm looking for a way for my retailers to upload inventories to our web site. I know how to upload a single file to the database, but I need for this file to be parsed. I'm thinking a comma-delimited file would make sense.

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!

ratebeer

11:24 pm on Jan 8, 2005 (gmt 0)

10+ Year Member



To further explain, I would want the above text file parsed in order to put this information into a SQLServer database table with something like the following statement.

' 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

IanTurner

12:04 am on Jan 9, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Unless you want to give your retailers direct access to the SQL Server, the upload of a delimited file is probably the most effective way.

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.

ratebeer

1:06 am on Jan 9, 2005 (gmt 0)

10+ Year Member



Thanks for the ntoe. I've done some Google searches for "inventory file upload ASP" and haven't found anything like this. Any recommendations on what I could do to find some base code?

aspdaddy

8:40 pm on Jan 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Heres an example of using the fso and split():
[webmasterworld.com...]

You just need to add the code execute (or build) SQL.

IanTurner

10:38 pm on Jan 9, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



If you need to do the upload via a web page look for ASP Upload components - there are quite a few commercial ones avaialble and one or two free ones.