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

x
?
Solved

Query to insert multiple values into single column

Posted on 2009-04-16
7
Medium Priority
?
613 Views
Last Modified: 2012-06-21
I have an ASPX page with 15 date fields, not all are required.
My data table has a single Date Column (Holidays)

How can I insert upto 15 values into a single column? I have tried the below method but get an error.
insCmd.CommandText = "INSERT into Holidays (Holidays) values('" & _
        txtHol1.Text & "','" & txtHol2.Text & "','" & txtHol3.Text & "','" & txtHol4.Text & "','" & txtHol5.Text & "','" & _
        txtHol6.Text & "','" & txtHol7.Text & "','" & txtHol8.Text & "', '" & txtHol9.Text & "','" & _
        txtHol10.Text & "','" & txtHol11.Text & "','" & txtHol12.Text & "','" & txtHol13.Text & "','" & txtHol14.Text & "','" _
        & txtHol15.Text & "')"

Open in new window

0
Comment
Question by:ITHelper80
  • 3
  • 3
7 Comments
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 24158287
You can't insert multiple values into a single column within the same record. What you can do is to insert multiple values into the same column in multiple rows. Otherwise I guess you will have to do a workaround and concatenate the values or create a new table for a 1 to n relation in which the relation table will contain the values.
0
 
LVL 6

Author Comment

by:ITHelper80
ID: 24158318
Thanks, I should clarify myself.

I am trying to insert multiple values into the same columns in multiple rows. I guess my query doesnt reflect that attempt.
0
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!

 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 24158446
Have a look at this ... here multi-row insters are described

http://en.wikipedia.org/wiki/Insert_(SQL)

INSERT INTO ''TABLE'' (''column1'', [''column2, ... ''])
VALUES (''value1a'', [''value1b, ...'']),
       (''value2a'', [''value2b, ...'']),
       ...
0
 
LVL 6

Author Comment

by:ITHelper80
ID: 24159017
Thanks but none of these are working....I think its worth mentioning that I am trying to INSERT into an Access database.
0
 
LVL 20

Accepted Solution

by:
ChristoferDutz earned 2000 total points
ID: 24159345
Well I think I have to quit here ... possibly you will have to start thinking of inserting them all with individual instert statements.
0
 
LVL 6

Author Comment

by:ITHelper80
ID: 24169016
I got it working with Individual Insert commands.....guess I should have done that from the get go. I spent more time "researching" than writing code.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
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

830 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