Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
any one can you help me how to use select multiple table from one dropdown list and different field from another dropdown list?
Thanks
Posted
Comments
fjdiewornncalwe 28-Dec-11 13:56pm    
Can you add a little more detail to your question, please? As your question is written right now, it makes no sense, but perhaps if you show an example or something of that sort it would help us to understand your issue.
#realJSOP 28-Dec-11 14:07pm    
I think this is a job for Liquid Nitrogen (or CListCtrl).
RaviRanjanKr 28-Dec-11 14:12pm    
Not clear! please be more clear while asking question we need more information about your question.
Monjurul Habib 28-Dec-11 14:55pm    
need more clarification !!!

1 solution

your question is not clear, but i think this may help you

declare SqlConnection con with desired connection string, SqlCommand cmd, SqlDataReader reader, string selectSQL and 2 ComboBox combobox1&combobox2
C#
selectSQL = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES";
cmd = new SqlCommand(selectSQL, con);
con.Open();
reader = cmd.ExecuteReader();
while (reader.Read())
{
     comboBox1.Items.Add(reader.GetString(0).ToString());
}
reader.Close();


use below code in SelectedIndexChanged event of combobox
C#
selectSQL = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = "+"'"+comboBox1.Text+"'";
cmd = new SqlCommand(selectSQL, con);
reader = cmd.ExecuteReader();
while (reader.Read())
{
     comboBox2.Items.Add(reader.GetString(0).ToString());
}
reader.Close();


--theanil
 
Share this answer
 
v6

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