Click here to Skip to main content
15,884,986 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Comments
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 this.how can i store these values in a string one by one as user enter the values.

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.
 
Share this answer
 
Comments
Karwa_Vivek 7-Nov-12 9:22am    
can you explain your solution with an example
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:

Suppose,
--------------------
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)

SQL
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.
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900