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 to the CF scene
    Join Date
    Aug 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to import the textarea data into database

    Dear All,

    I have searched a lot at GOOGLE, but i can't found the way to import data from a form textarea into database.

    Actually my web page would like to allow the user to export their phone book from excel file or outlook phone book, then import into my database.

    I was thinking to provide a textarea for the user to COPY and PASTE their address book from the text file and then my web page will read line by line to store the data into the database.

    Example data:

    abc, abc@hotmail.com, 999999999

    bcd, bcd@hotmail.com, 888888888

    i can't find any solution that can read line by line, because normally when the we parse the data from the form textarea. All the text will become string that without the <br>.

    Please HELP !!

    Thanks.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,032
    Thanks
    0
    Thanked 248 Times in 245 Posts
    Parse it using vbCrLf

  • #3
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sorry. can u pls show me how to parse vbCrLf?

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,032
    Thanks
    0
    Thanked 248 Times in 245 Posts
    Code:
    dim lines
    lines = split(request.form("textareaName"), vbCrLf)
    for i = 0 to ubound(lines)
       response.write "line " & (i+1) & ":" & lines(i) & "<br />"
    next

  • #5
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by glenngv
    Code:
    dim lines
    lines = split(request.form("textareaName"), vbCrLf)
    for i = 0 to ubound(lines)
       response.write "line " & (i+1) & ":" & lines(i) & "<br />"
    next
    Hey is there a page that i could go reading about all these vbCrLf's and vbNewLine's? A page that has all of them and what they are and represent?

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,032
    Thanks
    0
    Thanked 248 Times in 245 Posts

  • #7
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the coding that u provided is working very well, but i still get some error for the below coding.

    Code:
    <%
    strAddress = request.form("textarea")
    arrAddress = Split(strAddress, vbCrLf) 'Here vbCrLf is the delimiter
    For i = 0 to UBound(arrAddress)
     strSingleAddress1 = Split(strSingleAddress, ",")
      response.write strSingleAddress1(0) & "<br>"
      response.write strSingleAddress1(1) & "<br>"
      response.write strSingleAddress1(2) & "<br>"
     response.write "<br>"
    Next
    %>
    The error message is:
    Error Type:
    Microsoft VBScript runtime (0x800A0009)
    Subscript out of range: '[number: 0]'

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,032
    Thanks
    0
    Thanked 248 Times in 245 Posts
    You're trying to split an empty string (strSingleAddress) resulting to an array with ubound of -1, which means there is no element in the array thus the out of bounds error.
    Code:
    <%
    strAddress = request.form("textarea")
    arrAddress = Split(strAddress, vbCrLf) 'Here vbCrLf is the delimiter
    For i = 0 to UBound(arrAddress)
     strSingleAddress1 = Split(strSingleAddress, ",")
      response.write strSingleAddress1(0) & "<br>"
      response.write strSingleAddress1(1) & "<br>"
      response.write strSingleAddress1(2) & "<br>"
     response.write "<br>"
    Next
    %>
    Change the red part to arrAddress(i)

  • #9
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    also, you can use

    For i = LBound(arrAddress) to UBound(arrAddress)

    LBound almost always returns 0, but not always


  •  

    Posting Permissions

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