Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Feb 2007
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation upload file and insert its contents to database

    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

  • #2
    New Coder
    Join Date
    Feb 2007
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Google for Pure ASP Upload.

  • #4
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #5
    New Coder
    Join Date
    Feb 2007
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation insert contents of file from any client into my database in the server without uploa

    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

  • #6
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    Quote Originally Posted by anitha2324 View Post
    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.
    I am the luckiest man in the world

  • #8
    New Coder
    Join Date
    Feb 2007
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #9
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    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:
    Code:
    import from 'c:\data.csv' of del insert into tablename;


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •