...

View Full Version : upload file and insert its contents to database



anitha2324
04-13-2007, 10:07 AM
i want to allow the user to upload a text file from any system in the network and insert the contents of this text file into a table in the database ( oracle database)

so how i can do this in ASP

anitha2324
04-13-2007, 11:28 AM
by the way the text file looks like (phone no , name)
i mean it contents look like

1234,David Lord
4567,Ronaldo Math
712,Terry Henry

..............

which means i need to insert 2 fields into the table (the table contains 2 columns)
and so on

glenngv
04-14-2007, 10:46 PM
Google for Pure ASP Upload (http://www.google.com/search?q=pure+asp+upload).

degsy
04-18-2007, 02:11 PM
After you have uploaded the file to the server you can read it using the FSO
http://www.w3schools.com/asp/asp_ref_textstream.asp

then split the lines at the comma.
http://www.w3schools.com/vbscript/func_split.asp

You can then insert each part of the split into your update query.
http://www.w3schools.com/ado/ado_add.asp

anitha2324
04-19-2007, 12:14 AM
Thanks alot to All and my special thanks to Degsy,

it is working fine and i got successed in that .

but i have another question , actually my aim purpose is to insert the contents of selected file (selected by the user) into the database,

so can i insert the contents of file (selected by the user from any client) into the table in the server database directly without uploading this file to the server

degsy
04-19-2007, 10:33 AM
If it is a website based system then you have two methods.

1) Have a form to enter each line of data, then submit the form and insert the data to the database

2) Have a text file that includes the data and upload the file to the server and let ASP read it and insert the contents to the database.

So you are doing it in the correct way at the moment.

Roelf
04-19-2007, 11:03 AM
Thanks alot to All and my special thanks to Degsy,

it is working fine and i got successed in that .

but i have another question , actually my aim purpose is to insert the contents of selected file (selected by the user) into the database,

so can i insert the contents of file (selected by the user from any client) into the table in the server database directly without uploading this file to the server
Then you would have to read that file on the client from within your webpage. This is a security issue so you can not do that. Unless you are sure your audience is using IE, then you can use the filesystemobject as an activex-object within javascript (so u can utilize that in your webpage), which does give access to the local filesystem on the clients machine.

anitha2324
04-19-2007, 09:14 PM
thanks alot to all for their helps and answers.

I dont have form to enter the data line by line and then insert it to the database,(because the data will come in form of text files , so entering the data of the text file into a form one by one and then insert them one by one will take lot of time ,imagine i have 10,000 records inside the text file )

so i have a text file this text file contains alot of data ( 10,000 records or more ), the format of the text file look like this

1234,David Lord
4567,Ronaldo Math
712,Terry Henry
...........
.........


so my requirement is : to insert this contents of the file (10,000 records or more ) into the server database ( oracle database ) directly without the need for uploading this text file into the server ,

because uploading files to server daily will occupy space and i have to delete them manually otherwise to create script or write code for deleting those files from the server after the successful insertion of the file contents to the database.


so is there any way for doing it without uploading the files or it is necessary to upload the files and then insert them

glenngv
04-19-2007, 10:23 PM
I think it would be a lot easier if you upload the file to the server, execute the import command to the oracle and then delete the file. I don't know how the import command looks like in Oracle but here's how in DB2:

import from 'c:\data.csv' of del insert into tablename;



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum