Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have two text box for add contact number ..i assign one text box for one variable because only one column for add contact number in database I want to add both field input for one column in database..

What I have tried:

I have no idea for tried anything.. because Iam a beginner..
Posted
Updated 8-Dec-22 0:59am
Comments
Richard MacCutchan 8-Dec-22 6:50am    
Your question does not make a lot of sense. What information do you want in the second textbox?
Graeme_Grant 8-Dec-22 6:53am    
probably area code & number ...
Richard MacCutchan 8-Dec-22 6:55am    
Possibly, but that would still make little sense.
Graeme_Grant 8-Dec-22 7:09am    
I know, but we are talking about beginners. But now resolved.
Rajitha Madhushan 8-Dec-22 6:56am    
I have two text boxes for for contact number (contact no1 and contact no2) I make a variable for assign text box .
Int cont;
cont = text box.text;
I want to assign both textbox for same variable name .is it possible?

1 solution

I would suggest that the best solution would be to change the DB: add a table which holds a contact number, and a Foreign Key back to your original table.

You can that add multiple contact number to a single contact, and retrieve them using a JOIN clause.

The other solution is to hope the existing field is defined as NVARCHAR and long enough to hold many contact numbers, then store your text boxes as commas separated data. That gets really messy later though and it's normally a good way to get some really hair pulling problems when you start modifying your app later.

Remember, many people have multiple contact numbers: home, work, mobile, work mobile, whatsapp, ... restricting this to two is probably a bad idea.
 
Share this answer
 
Comments
PIEBALDconsult 8-Dec-22 12:32pm    
I'd make it a many-to-many relationship.

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