如何在Com框中删除重复 [英] How Can Remove Duplicate In The Com box

查看:40
本文介绍了如何在Com框中删除重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Com框中删除重复







//子类别

尝试

{

DataTable dt9 = new DataTable();

// string CS9 = ConfigurationManager.ConnectionStrings [DBCS ] .ConnectionString;



{

string query9 =从tblcatProducts中选择DISTINCT catName1;



SqlDataAdapter da9 = new SqlDataAdapter(query9,con2);

con2.Open();

DataSet ds9 = new DataSet();

da9.Fill(ds9,tblcatProducts);

comboBoxSub1.DisplayMember =catName1;

comboBoxSub1.ValueMember =catId;

comboBoxSub1.DataSource = ds9.Tables [tblcatProducts];

}

}

catch {}

How Can Remove Duplicate In The Com box



//Sub Category
try
{
DataTable dt9 = new DataTable();
//string CS9 = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;

{
string query9 = "select DISTINCT catName1 from tblcatProducts ";

SqlDataAdapter da9 = new SqlDataAdapter(query9, con2);
con2.Open();
DataSet ds9 = new DataSet();
da9.Fill(ds9, "tblcatProducts");
comboBoxSub1.DisplayMember = " catName1";
comboBoxSub1.ValueMember = "catId";
comboBoxSub1.DataSource = ds9.Tables["tblcatProducts"];
}
}
catch { }

推荐答案

什么是Com box?我认为你是在引用一个ComboBox?



你的SQL代码已经摆脱了重复,所以你必须准确地定义什么你的意思是复制并提供示例。



太糟糕了,你的SQL查询不会返回 catId 数据库中的列。看起来这样做非常重要。



另外,你的变量名称很糟糕。使用描述性名称,而不是此 query9 废话。你正在做的就是通过做你正在做的事情来使代码更难调试和维护。
What's a "Com box"? I take it you're refering to a ComboBox?

You SQL code is already getting rid of duplicates, so you're going to have to define in precise terms what you mean by "duplicate" and provide examples.

Too bad you're SQL query doesn't return the catId column from your database. It looks like it would be pretty important to do so.

Also, your variable names suck ass. Use descriptive names, not this query9 crap. All you're doing is making your code harder to debug and maintain by doing what you're doing.


这篇关于如何在Com框中删除重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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