Textfield - Multi Field insert

Hello All;

  Got something that i have been wondering how to do for several years now.
(When it comes to me, I think about how it could be done)

have it to where each line does a break. (String)
And then you look at each break in the textfield, to determin how many strings you have.
You then have an INSERT Statement that will insert each line (String) into indivisual fields.
(Multi Field insert statement)

To break it down.
Take a continues string from a Textfield
Break it down to indivisual strings (Per row)
And insert indivisual records into a Table.

Hope that it is clear.
Just something that I have been wondering about for a while.
What made me thing about it was that I have an Old Perl script
That uses a Textfield and for each row, it inserts into the MySQL database.
If it can be done in Perl/MySQL
It should be able to be done in ASP/Access (or) (SQL Server)
(I am using Access)

have a good one all.
LVL 31
Wayne BarronAuthor, Web DeveloperAsked:
Who is Participating?
aibusinesssolutionsConnect With a Mentor Commented:
Well it's not actually a continuous string, it would be split up by carriage returns.

ASP would see it as
first line#10#13second line#10#13third line#10#13fourth line

To loop through an array and insert the values you could do something like this:

set conn=Server.CreateObject("ADODB.Connection")
conn.Open "c:/webdata/myaccessfile.mdb"
Dim strArray = Split(Request.Form("MyTextField"), vbCrLf)
Dim arrValue
For Each arrValue In strArray
   Dim sql
   sql = "INSERT INTO myTable (Column1) VALUES ('" & arrValue & "')"

Open in new window

Do you mean line by line? I would just split the string by vbCrLf.

strArray = Split(txtBoxText, vbCrLf)

That will put the values into an array, so
strArray(0) = first line
strArray(1) = second line

Then just loop throw the array and insert each string.
Wayne BarronAuthor, Web DeveloperAuthor Commented:
I have read something about this before.
Would you have some resources on this, or possibly could you make up a souce example?

Thanks AI
You are actually the first person that has said that it is possible.
The last time that I posted this same topic years ago, I was told that
You could not take a continues string and split it.
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Wayne BarronAuthor, Web DeveloperAuthor Commented:
I am getting this error

Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/Test/EE/Q_24163759/Insert.asp, line 16, column 13
Dim strArray = Split(Request.Form("MyTextField"), vbCrLf)
Oh, I'm thinking in asp.net, just split it into two lines.

Dim strArray
strArray = Split(Request.Form("MyTextField"), vbCrLf)
Wayne BarronAuthor, Web DeveloperAuthor Commented:

I have thought about venturing into ASP.NET
But I am just know getting to where I can do a lot of things in ASP Classic.
So, I will wait until there is something that I want to do, that can only be done in .NET.
Wayne BarronAuthor, Web DeveloperAuthor Commented:
I'll be darn.

Worked like a charm.
You did what others said could not be done.
That was so simple. You have just done something that I have wanted to do for years in ASP.
Proven that ASP is just as powerful as PERL

Thank you so very, very much.

Wayne BarronAuthor, Web DeveloperAuthor Commented:
You Rock BIG TIME.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.