[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Textfield - Multi Field insert

Posted on 2009-02-20
8
Medium Priority
?
333 Views
Last Modified: 2012-05-06
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)

Textfield.
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)

So.
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.
So.
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.
Carrzkiss
0
Comment
Question by:Wayne Barron
  • 5
  • 3
8 Comments
 
LVL 15

Expert Comment

by:aibusinesssolutions
ID: 23697775
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
etc.

Then just loop throw the array and insert each string.
0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 23697908
OK.
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.
0
 
LVL 15

Accepted Solution

by:
aibusinesssolutions earned 2000 total points
ID: 23697944
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.Provider="Microsoft.Jet.OLEDB.4.0"
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 & "')"
   conn.Execute(sql)
Next
 
conn.Close

Open in new window

0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
LVL 31

Author Comment

by:Wayne Barron
ID: 23697985
strange.
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)
------------^
0
 
LVL 15

Expert Comment

by:aibusinesssolutions
ID: 23697990
Oh, I'm thinking in asp.net, just split it into two lines.

Dim strArray
strArray = Split(Request.Form("MyTextField"), vbCrLf)
0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 23698008
:)

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.
0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 23698031
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
0
 
LVL 31

Author Closing Comment

by:Wayne Barron
ID: 31549489
You Rock BIG TIME.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ready to get certified? Check out some courses that help you prepare for third-party exams.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question