473,387 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Comma delimited array into DB problems


From: "Arne de Booij" <a_********@hotmail.com>
Subject: Comma delimited array into DB problems
Date: 9. februar 2004 10:39

Hi,

I have an asp page that takes input from a form on the previous page,
puts that into an array and inserts the array into SQL server.

Now here is the problem:

The form on the page where the user can enter information contains a
dynamic amount of text boxes with the same name. So when the user
submits their entry, I get a comma delimited string.

e.g. First entry, Second entry, Third entry

The problem comes when a user enters a comma in the text field

e.g. First entry, with a comma, Second entry, Third Entry.

My code will put "with a comma" into a different row in the DB than
"First entry" because of the comma in the string.

Any ideas on how to solve this?
CODE (somewhat simplified)

Detailsvar = request("details")
details = Replace(Detailsvar, "'", "''") 'array

Dim deArray
deArray = Split(details, ", ")

FOR i = Lbound(deArray) TO Ubound(deArray)
DB.Execute("sp_insert_ratings '" & deArray(i) & "'")
NEXT

Arne

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #1
4 2801
How do you the values into a comma delimited string?

"Arne" <a_********@hotmail.com> wrote in message
news:eh**************@TK2MSFTNGP11.phx.gbl...

From: "Arne de Booij" <a_********@hotmail.com>
Subject: Comma delimited array into DB problems
Date: 9. februar 2004 10:39

Hi,

I have an asp page that takes input from a form on the previous page,
puts that into an array and inserts the array into SQL server.

Now here is the problem:

The form on the page where the user can enter information contains a
dynamic amount of text boxes with the same name. So when the user
submits their entry, I get a comma delimited string.

e.g. First entry, Second entry, Third entry

The problem comes when a user enters a comma in the text field

e.g. First entry, with a comma, Second entry, Third Entry.

My code will put "with a comma" into a different row in the DB than
"First entry" because of the comma in the string.

Any ideas on how to solve this?
CODE (somewhat simplified)

Detailsvar = request("details")
details = Replace(Detailsvar, "'", "''") 'array

Dim deArray
deArray = Split(details, ", ")

FOR i = Lbound(deArray) TO Ubound(deArray)
DB.Execute("sp_insert_ratings '" & deArray(i) & "'")
NEXT

Arne

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #2
You could treat the form element as a collection, rather than as a comma
separated string.

<form method=post>
<input type=text name=x value="a, b">
<input type=text name=x value="c">
<input type=text name=x value="d">
<input type=submit>
</form>

<%
for i = 1 to request.form("x").count
response.write request.form("x")(i) & "<br>"
next
%>

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"Arne" <a_********@hotmail.com> wrote in message
news:eh**************@TK2MSFTNGP11.phx.gbl...

From: "Arne de Booij" <a_********@hotmail.com>
Subject: Comma delimited array into DB problems
Date: 9. februar 2004 10:39

Hi,

I have an asp page that takes input from a form on the previous page,
puts that into an array and inserts the array into SQL server.

Now here is the problem:

The form on the page where the user can enter information contains a
dynamic amount of text boxes with the same name. So when the user
submits their entry, I get a comma delimited string.

e.g. First entry, Second entry, Third entry

The problem comes when a user enters a comma in the text field

e.g. First entry, with a comma, Second entry, Third Entry.

My code will put "with a comma" into a different row in the DB than
"First entry" because of the comma in the string.

Any ideas on how to solve this?
CODE (somewhat simplified)

Detailsvar = request("details")
details = Replace(Detailsvar, "'", "''") 'array

Dim deArray
deArray = Split(details, ", ")

FOR i = Lbound(deArray) TO Ubound(deArray)
DB.Execute("sp_insert_ratings '" & deArray(i) & "'")
NEXT

Arne

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #3

The form on the page where the user can enter information contains a
dynamic amount of text boxes with the same name.

e.g.

<FORM ...>
Textbox1: First comment
<BR>
Textbox1: Second comment
<BR>
Textbox1: Third comment
<BR>
</FORM>

When you submit this and request it on the next page
(request("Textbox1")) you get the string: First comment, Second comment,
Third comment.

So it is basically automatic.
How do you the values into a comma delimited string?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #4
Hi Aaron,

your comment sent me in the right direction. I was able to make minor
adjustments to the entire code to get it to work.

thanks!
___________

"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:eK**************@TK2MSFTNGP11.phx.gbl...
You could treat the form element as a collection, rather than as a comma
separated string.

<form method=post>
<input type=text name=x value="a, b">
<input type=text name=x value="c">
<input type=text name=x value="d">
<input type=submit>
</form>

<%
for i = 1 to request.form("x").count
response.write request.form("x")(i) & "<br>"
next
%>

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"Arne" <a_********@hotmail.com> wrote in message
news:eh**************@TK2MSFTNGP11.phx.gbl...

From: "Arne de Booij" <a_********@hotmail.com>
Subject: Comma delimited array into DB problems
Date: 9. februar 2004 10:39

Hi,

I have an asp page that takes input from a form on the previous page,
puts that into an array and inserts the array into SQL server.

Now here is the problem:

The form on the page where the user can enter information contains a
dynamic amount of text boxes with the same name. So when the user
submits their entry, I get a comma delimited string.

e.g. First entry, Second entry, Third entry

The problem comes when a user enters a comma in the text field

e.g. First entry, with a comma, Second entry, Third Entry.

My code will put "with a comma" into a different row in the DB than
"First entry" because of the comma in the string.

Any ideas on how to solve this?
CODE (somewhat simplified)

Detailsvar = request("details")
details = Replace(Detailsvar, "'", "''") 'array

Dim deArray
deArray = Split(details, ", ")

FOR i = Lbound(deArray) TO Ubound(deArray)
DB.Execute("sp_insert_ratings '" & deArray(i) & "'")
NEXT

Arne

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ricky Cruz | last post by:
Hi, On SQLServer 2000, I have a table with a following structure: MYTABLE col1 char, col2 date, col3 number My Objective:
4
by: Christine Forber | last post by:
I wonder if anyone knows of some javascript code to check a comma-delimited list of email addresses for basic formating. What I'm looking for is the javascript code to check a form field on form...
1
by: John B. Lorenz | last post by:
I'm attempting to write an input routine that reads from a comma delimited file. I need to read in one record at a time, assign each field to a field array and then continue with my normal...
9
by: Bernie Yaeger | last post by:
Is there a way to convert or copy a .xml file to a comma delimited text file using vb .net? Thanks for any help. Bernie Yaeger
3
by: Avi | last post by:
I need to create a text file that has the data from the 10 tables in the database. The number of fields in the tables exceeds 255 and so I cannot make a new table with all the fields and then...
4
by: newsprofile | last post by:
Can anyone point me in the right direction on how to deal with an xls flie. Sorry to be basic in my request, but the only other file I have to work with is pdf. I'm not sure, is xls the...
15
by: VMI | last post by:
I'm parsing a comma-delimited record but I want it to do something if some of the string is between "". How can I do this? With the Excel import it does it correct. I'm using String.Split()....
4
by: JustSomeGuy | last post by:
Hi. I have a comma delimited text file that I want to parse. I was going to use fscanf from the C library but as my app is written in C++ I thought I'd use the std io stream library... My Text...
2
by: Jim | last post by:
Hello: I have a variable which contains a comma delimited list contained in a database variable e.g. "5,6,9,10,55,42" - I want to hand this list to an array function to get it to populate an...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.