Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: uploaded csv file insert into sql database


Message #1 by james@c... on Wed, 15 Aug 2001 19:12:24
Hi,

I need to allow people to upload a csv file then somehow insert the csv 

file to an sql database can anyone point me in the right direction? i cant 

find anything relative anywhere on the net. any help is appreciated

Message #2 by "Craig Flannigan" <ckf@k...> on Thu, 16 Aug 2001 08:44:20 +0100
Break it down into steps...



1. Provide a page with an Upload facility.

http://www.websupergoo.com/abcupload-1.htm

I use a free one called ABCUpload 4.1 on our 400-client Intranet and have

never had a problem. It provides more functionality that I will need, and

it's quick - most importantly, it's free too!

Get the upload script to save to a specified directory.





2. Open the CSV file and parse it line by line. Use the FileSystemObject to

do this.



If you know what delimiters have been used to separate the fields, then you

can use the Split() command. This takes each "field" from the line and puts

it into an array. This will then let you build the Insert Into statement for

the Database



	strArrayName = Split(strDataLine,",")



strDataline is the variable that is holding a line of text from the CSV

file.

strArrayName now holds the separated fields, which you access by using an

array index.



	strArrayName(0) = the first field

	...

	strArrayName(9) = the last (assuming you have 10 fields)





To obtain the total number of fields should you not know it, can be done by

using the UBound statement.



	strTotalFields = UBound(strArrayName)





3. Now you've got your line split into "fields" you can go ahead and build

the Insert Into statement. E.G:



	"Insert Into TableName (field1, field2) VALUES(" & strArrayName(0) & "," &

strArrayName(1) & ");"







Hope this gives you some guidance.



Good luck!

Regards,

Craig.







-----Original Message-----

From: james@c... [mailto:james@c...]

Sent: Wednesday 15 August 2001 19:12

To: ASP Databases

Subject: [asp_databases] uploaded csv file insert into sql database





Hi,

I need to allow people to upload a csv file then somehow insert the csv

file to an sql database can anyone point me in the right direction? i cant

find anything relative anywhere on the net. any help is appreciated

Message #3 by "Tomm Matthis" <matthis@b...> on Fri, 17 Aug 2001 06:49:02 -0400
If you're using SQL server, look into using DTS (Data Transformation

Services) that come with SQL server.



-- Tomm



> -----Original Message-----

> From: james@c... [mailto:james@c...]

> Sent: Wednesday, August 15, 2001 7:12 PM

> To: ASP Databases

> Subject: [asp_databases] uploaded csv file insert into sql database

>

>

> Hi,

> I need to allow people to upload a csv file then somehow insert the csv

> file to an sql database can anyone point me in the right

> direction? i cant

> find anything relative anywhere on the net. any help is appreciated


  Return to Index