...

View Full Version : How to import the textarea data into database



superman2004
01-20-2005, 04:20 AM
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.

glenngv
01-20-2005, 06:02 AM
Parse it using vbCrLf

superman2004
01-20-2005, 06:51 AM
sorry. can u pls show me how to parse vbCrLf?

glenngv
01-20-2005, 02:23 PM
dim lines
lines = split(request.form("textareaName"), vbCrLf)
for i = 0 to ubound(lines)
response.write "line " & (i+1) & ":" & lines(i) & "<br />"
next

jaywhy13
01-21-2005, 05:27 AM
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?

glenngv
01-21-2005, 05:41 AM
It's just one google away.
http://vb2py.sourceforge.net/docs/vbconstants.html

superman2004
01-24-2005, 02:10 AM
the coding that u provided is working very well, but i still get some error for the below coding.



<%
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]'

glenngv
01-24-2005, 10:10 AM
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.


<%
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)

ghell
01-25-2005, 12:26 PM
also, you can use

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

LBound almost always returns 0, but not always :p



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum