![]() |
Checkboxes not update in asp database
I have a list of checkboxes like 1,2,3,4,5 when I use update statement I get 1 instead of 1,2,3,4,5 in my database column. I have checked to make sure request.form is returning 1,2,3,4,5 and it is but it only update one value instead of the array of numbers. Is there a simple way to get this to update correctly? Thanks for your help in advance.
|
You do *NOT* want "1,2,3,4,5" in your database column. PERIOD.
You should *NEVER* store a LIST of values in a single field in a database. You should store each checkbox in a SEPARATE RECORD, probably in a separate many-to-one table. You don't show us your DB design. You don't show use your code. There's not much more we can help you with until you share more of your problem. |
This is an array and it is a very useful way to get checkboxes info from your users an put it one database column.
Update statement Code:
NMGroups = Request.Form("NMGroups")I just need the array of numbers to update to one table called NMGroups in my database. Right now it works in my insert statement but when I us the update statement it only grabs the first number in the array. How do I grad all numbers like 1,2,3,4 and save it. |
I will say it one more time: That is *TERRIBLE TERRIBLE* database design.
Even if you only read the first few paragraphs of any book or article on DATABASE NORMALIZATION you will learn that. And any GOOD book or article on database design *WILL* include a section on normalization, guaranteed. But if you are going to do this despite what any database designer will tell you, then at least show us the *CODE* that you say is not working. What does the design of your table NMGroups look like, for starters? What does the SQL query that you are using to do UPDATE NMGroups ... look like? |
NMGroups is a number field in the database. the update script listed below updates but only puts 1 number instead of the array of numbers like 1,2,3,4 my insert statement on a different page works fine. Just when the use goes to update this list it only put 1 number when 1,2,3,4 are checked.
|
Quote:
It must be a text field of some kind or it could never hold more than one number. ********* DEBUG DEBUG DEBUG Code:
... |
fixed it I forgot to remove the whitespace used replace(request.form("NMGroups"), " ", "") 1, 2, 3, 4 almost looks like1,2,3,4 when I did the response.write to verify the form.
|
Don't see why a space would matter. The data should have been inserted/update anyway, just that it would have spaces in it.
|
| All times are GMT +1. The time now is 08:59 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.