Read from text area

Discussion in 'ASP General' started by Mark Fisher, Dec 23, 2004.

  1. Mark Fisher

    Mark Fisher Guest

    Hi

    I have a database on a website, and a table in this db contains two fields,
    PCode, and Verified. I have to add new records to this in batches, and
    these batches are generated on a local PC.

    Is it possible to paste the contents of a text file into a text area form
    field, and then run an asp/vbscript routine to update the database.

    The text file contents to be pasted would be in the format:

    1234, Y
    1235, N
    1236, Y

    I am ok with updating the database, what I would like to know is how to
    split the text into individual items - is there some kind of read line
    function.

    Thanks
     
    Mark Fisher, Dec 23, 2004
    #1
    1. Advertisements

  2. Mark Fisher

    Scott McNair Guest

    "Mark Fisher" <> wrote in
    news:KxDyd.1466$:

    > Is it possible to paste the contents of a text file into a text area
    > form field, and then run an asp/vbscript routine to update the
    > database.


    Set Cn = Server.CreateObject("ADODB.Connection")
    Cn.ConnectionString = "[...]"
    RowArray = Split(Request.Form("MyTextBox"),vbcrlf)
    For Each Item In RowArray
    Cn.Execute "Insert Into MyTable (Field1, Field2) Values '" & Trim(Split
    (Item,",")(0)) & "', '" & Trim(Split(Item,",")(1)) & "'"
    Next
    Set Cn = Nothing

    Untested code, but it should work for you.
     
    Scott McNair, Dec 23, 2004
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark
    Replies:
    1
    Views:
    802
    Larry Barowski
    Jun 27, 2005
  2. hotadvice
    Replies:
    14
    Views:
    1,016
    hotadvice
    Oct 2, 2007
  3. Andy B.
    Replies:
    0
    Views:
    1,050
    Andy B.
    Apr 30, 2010
  4. leo
    Replies:
    1
    Views:
    488
    Bob Lehmann
    Dec 5, 2005
  5. leo

    Controlling text in a Text Area

    leo, Dec 5, 2005, in forum: ASP General
    Replies:
    3
    Views:
    335
    Evertjan.
    Dec 6, 2005
  6. Replies:
    0
    Views:
    364
  7. Jim
    Replies:
    0
    Views:
    339
  8. Andy Burghardt

    Checkbox to load text into text area

    Andy Burghardt, Jan 31, 2008, in forum: Javascript
    Replies:
    2
    Views:
    266
    Andy Burghardt
    Jan 31, 2008
Loading...