Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a dropdownlist which consists of numbers from 1 to 10.
based on user selection respective dropdownlists will get displayed.
i need to store the dropdownlists values in sql database.
My doubt is whether i need to create 10 columns in the database or can i add columns dynamically in db based on user selection.
Posted
Comments
kishore sharma 2-Apr-13 7:42am    
can you explain little more ,what output you want
sukumari1 2-Apr-13 8:42am    
user has to select no.of languages known.
if user selects 3 then 3 dropdownlists will appear. In that they have to select 3 languages.
as an eg, first dropdownlist user may select english, 2nd dropdownlist spanish and it goes on...
my doubt is to create how many columns in database. col1=english, col2=spanish...
because user may select maximum 10 languages. whether i need to create 10 columns or can i add columns at runtime based on user selection.

No, you need only 2 columns:
SQL
CREATE TABLE UserLangs (UserID INT, LangID INT)

where:
UserID is a foreign-key for users (data coming from MyUsers table)
LangID is a foreign-key for languages(data coming from Languages table)

The structure and relationships between tables should looks like:
MyUsers                   UserLangs                Languages
--------                  ---------                ---------
UserID INT (one <-- many) UserID          |-->one) LangID 
...(other fields)         LangID (many----|         ... (other fields)
 
Share this answer
 
Comments
sukumari1 3-Apr-13 7:46am    
can you help me... how to pass values from c# to these tables, also how to create stored procedure
Maciej Los 3-Apr-13 7:50am    
Yes, i can help you. Post new question and describe your issue with details. Show what you have done till now and where do you stuck. OK?
You can create and add columns to table using following
DataColumn col1= new DataColumn("Col_Name", typeof(string));
Datatable1.Columns.Add(col1);
Datatable1.acceptchanges()


Hope its what you are looking for....
 
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