asp.net选择多个表 [英] asp.net select multiple table
本文介绍了asp.net选择多个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
任何人都可以帮助我,如何使用一个下拉列表中的多个表,以及另一个下拉列表中的不同字段?
谢谢
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
推荐答案
您的问题不清楚,但我认为这可能对您有所帮助
使用所需的连接字符串,SqlCommand
cmd,SqlDataReader
读取器,string
selectSQL和2ComboBox
combobox1& combobox2
声明SqlConnection
con
your question is not clear, but i think this may help you
declareSqlConnection
con with desired connection string,SqlCommand
cmd,SqlDataReader
reader,string
selectSQL and 2ComboBox
combobox1&combobox2
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();
在组合框的SelectedIndexChanged事件中使用以下代码
use below code in SelectedIndexChanged event of combobox
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
--theanil
这篇关于asp.net选择多个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文