如何使用C#.net在复选框中从SQL数据库中检索唯一值 [英] How to retrieve the unique values from sql database in checkbox using c#.net

查看:239
本文介绍了如何使用C#.net在复选框中从SQL数据库中检索唯一值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们在单列n中具有相同的值时,请帮助我,我们只想在复选框中显示n一次就检索该重复值.

Please help me when we have same values in single column n we wanna retrieve that repeated value only once n wanna display in our check box.

推荐答案

使用sql像从样本中选择distinct(id)"这样的quary,然后将检索到的id分配给复选框
例如:
use sql quary like "select distinct(id) from sample " and assign the retrived id to checkbox
ex:
da = New SqlDataAdapter("select distinct( name) from sample", con)
       ds = New DataSet()
       da.Fill(ds)
       CheckBox1.Text = ds.Tables(0).Rows(0)(0).ToString()



您可以使用以下查询

Ya
You can use following Query

select distinct( columnname) from tableName



但是如果记录"大于1,那么您如何在复选框中显示值?

我想你还想做点其他的事..

请清除.如果是



but if Records are more then 1 then how you display value in checkbox??

i think you want to do some other thing..

please clearify.?? if yes


这篇关于如何使用C#.net在复选框中从SQL数据库中检索唯一值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆