做combobox绑定时 combobox1绑定SQL数据库表系别表,根据系别名称,来找出对应班级表中的班级,并绑定在combobox2。系别表:系别号,系别名称;班级表:班级号,系别号,班级名;求代码? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 度娘搜索: combobox级联 site:cnblogs.com 一堆的 select * from 班级表 where 系别号 in (select 系别号 from 系别表 where 系别名称 = 你要查的名字) 第一个绑定的是 系别号, 第二个则绑定的是 班级号string xibiehao=combobox1.text;select * from 班级表 where 系别号='xibiehao'在 combox1中绑定变行了,你试试。 select * from 班级表 a,系别表 b where a.系别号=b.系别号 and a.系别名称 = 你要查的名字 string sql="Select * from 系别表"; DataTable Deptdt = DBHelper.GetTable(sql); combobox1.DataSource = Deptdt; combobox1.DisplayMember = "系别号"; combobox1.ValueMember = "系别名称"; private void cboDept_SelectedIndexChanged(object sender, EventArgs e) { string sql="select * from 班级表 a,系别表 b where a.系别号=b.系别号 and a.系别号 =combobox1.selectedValue"; DataTable ClassDt= DBHelper.GetTable(sql); combobox2.DataSource = ClassDt; combobox2.DisplayMember = "班级号"; combobox2.ValueMember = "班级名"; } DataTable ClassDt= DBHelper.GetTable(sql);,“ DBHelper”,不存在,看不懂!求解 DataTable ClassDt= DBHelper.GetTable(sql);,“ DBHelper”,不存在,看不懂!求解 5楼的DBHelper是另为定义的类,你把他看作得到了这张系表表 DBHelper里面应该包含 数据库连接,数据操作,你自己另外写一个就行 C#读写内存也不差!(发布C#编写的<植物大战僵尸>作弊器源码) 关于多线程操作Dictionary,很简单的代码,却令人诧异 C#记住程序状态 曲线图 截取了HTML文件,如何得到指定值 c#winform中怎么让datagrid绑定数据库 如何将一个二维数组存入到一个一维数组中? 使用smtp协议发邮件问题 大疑问!!!!!如何自定义一个控件的事件?可以在外部应用它? 请问在 c# WinForm程序中如何执行 外部的 .exe 文件? Winform DataGridView控件显示数据慢的问题 在“Resources”参数中指定了多次。“Resources”参数不支持重复项
一堆的
string xibiehao=combobox1.text;
select * from 班级表 where 系别号='xibiehao'在 combox1中绑定变行了,你试试。
DataTable Deptdt = DBHelper.GetTable(sql);
combobox1.DataSource = Deptdt;
combobox1.DisplayMember = "系别号";
combobox1.ValueMember = "系别名称";
private void cboDept_SelectedIndexChanged(object sender, EventArgs e)
{
string sql="select * from 班级表 a,系别表 b where a.系别号=b.系别号 and a.系别号 =combobox1.selectedValue";
DataTable ClassDt= DBHelper.GetTable(sql);
combobox2.DataSource = ClassDt;
combobox2.DisplayMember = "班级号";
combobox2.ValueMember = "班级名";
}