Click here to Skip to main content
13,346,664 members (65,657 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have a textBox
user enter values 1 and saves it in database.
when user saves the Value the form is not getting closed.
Next user enter value 2 and again saves it.
This time while saving the need is that it should save the Previous
value also means 1. Again when user enters 3 and saves this then .while saving
it should save 1,2,3 in database.How can I do this .
How to store these values in a string .until the Form is closed.
Can this be Done .
Please assist
How to do this.
Posted 7-Nov-12 3:41am
a1mimo 7-Nov-12 9:10am
yes this can be done but what is your problem exactly???
Karwa_Vivek 7-Nov-12 9:21am
my problem is how to do can i store these values in a string one by one as user enter the values.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I am not exactly sure what you are trying to achive but seems to me you could use an array or a list of strings to store the values.
Karwa_Vivek 7-Nov-12 9:22am
can you explain your solution with an example
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

From your details it looks like you have a column in database which you want to populate with the IDs (comma separated) entered by user.

At this point, your design does not seems to be much efficient. Rather than getting comma separated IDs you should create a separate table with Master/Child relationship to the existing one. So Instead of this:

Table A (Your way)
AutoID | IDs
1 | 1,2
2 | 1,2,4
3 | 3,4,7

It should be:

Table Master (My Recommendation)
AutoID | IDs
1 | 1 <--------- "AutoID" of "Table child"
2 | 2 <--------- "AutoID" of "Table child"
3 | 3 <--------- "AutoID" of "Table child"

Table Child
AutoID | IDs
1 | 1
1 | 2
2 | 1
2 | 2
2 | 4
3 | 3
3 | 4
3 | 7

It helps to manage data and make them easy to manipulate.

In case you can not change table structure, you need to update data by appending ID provided by user at the end, something like this: (Assuming SQL as backend)

update TableA set [Ids] = [Ids] + ',' + UserProvidedId 
WHERE <condition>

So if first row of column [Ids] has '1,2' and users entered 3 then update statement will make it '1,2,3'.

Now you can see in this comma seperated design it is hard to find duplicates without doing a SPLIT or SUBSTRING.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.180111.1 | Last Updated 7 Nov 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100