
ListBox1.DisplayMember=“列名” 显示项
ListBox1.ValueMember=“列名” 值项
楼上回答正确
必须有唯一标识列才能过滤重复,下面给你个思路:生成唯一id列:
select id=identity(1,1),bianhao、name、jiage、chandi、shuliang into #tmp_tb from 表1
查询显示name不重复的所有数据:
select * from #tmp_tb t1 where not exists (select 1 from #tmp_tb t2 where t2.name=t1.name and t2.id<t1.id)
bianhao列为唯一标示列,显示大的小的都可以
--------------------
那直接查就可以了:
select * from kucun t1 where not exists (select 1 from kucun t2 where t2.name=t1.name and t2.bianhao<t1.bianhao)
呵呵,如果你数据库中的数据会变动的话,那么最好在前台用select语句先取出数据,再绑定到listbox。如果你数据库中的数据不变动的话,那么先用datatable取出来,再绑定数据源到listbox就行。
其实这种题目用三层架构做比较好。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)