Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ScottBot
Starting Member
16 Posts |
Posted - 2010-12-15 : 11:59:12
|
| I have created a contact form that has a multiple choice listbox for a single subscriber. The asp.net code works fine in selecting single or multiple values for as many values are selected. The issue occurs when I try to do the insert process through the sproc.The sproc is trying to insert the persons name into a table to generate a user_ID, I then use SCOPE_IDENTITY() to get the ID and use it to insert that id plus the listbox values into a new table.What Im aiming for is that the second table ends up looking like below if a single user picked 3 listboxes.User_ID | selection_ID----------------------1 | 11 | 21 | 3Single user insert with a single listbox chosen inserts as expected.When I pick multiple listboxes it all goes wrong. It will insert the user name as many times as listboxes has been chosen. So if I picked 3 listboxes for user Tim it inserts Tim 3 times into the main table generating 3 user Id's for Tim and then inserts the value of one of the listboxes per User_ID so my table end up looking likeUser_ID | selection_ID----------------------1 | 12 | 23 | 3I assume it is doing this as it is looping through the sproc as many times as listbox items have been selected. Is there anyway to get it to realise it is a single user insert and should keep that id for as many times as it loops through?Any help would be much appreciated. |
|
|
SparkByte
Yak Posting Veteran
60 Posts |
Posted - 2010-12-15 : 16:12:53
|
| What if you put the values from the multiple list box selects into a dictionary and then inserted each of the values from the dictionary? Each insert would be handled via ASP.Thank You,John |
 |
|
|
|
|
|