惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
罗磊的独立博客
SecWiki News
SecWiki News
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
IT之家
IT之家
博客园 - 聂微东
T
The Exploit Database - CXSecurity.com
Recorded Future
Recorded Future
大猫的无限游戏
大猫的无限游戏
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Vercel News
Vercel News
G
GRAHAM CLULEY
D
DataBreaches.Net
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
SegmentFault 最新的问题
博客园_首页
雷峰网
雷峰网
T
Tenable Blog
Spread Privacy
Spread Privacy
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
Cisco Talos Blog
Cisco Talos Blog
V
Visual Studio Blog
J
Java Code Geeks
博客园 - Franky
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
C
CERT Recently Published Vulnerability Notes
T
Threatpost
Google DeepMind News
Google DeepMind News
F
Fortinet All Blogs
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
Recent Announcements
Recent Announcements
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
U
Unit 42
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
K
Kaspersky official blog
有赞技术团队
有赞技术团队
B
Blog
腾讯CDC

博客园 - zzh5945

桌面上IE图标不见了怎么办? Microsoft JET Database Engine 错误 '80004005' 完整解决办法 NTLDR - zzh5945 - 博客园 如何在企业管理器里面把非NULL值改为NULL值 虚拟机网络连接方式和网络设置 Excel中按方向不能移动单位格 禁止master扩展存储过程xp_cmdshell命令 关于HttpWebRequest发生服务器协议冲突的解决办法 查询远程数据库 无法在WEB服务器上启动调试.未能启动ASP.NET或ATL SERVER 调试 网上邻居的内容不会自动刷新的解决方案? 更改网上邻居的登陆信息 两招轻松找回遗忘的WinXP管理员密码 一款能够自动上传文件到ftp服务器的软件 怎样能使winform窗体的大小固定住,不能调整其大小 怎样让SQL只显示用户表 VS2005中解决方案管理器中看不到解决方案节点的解决办法 解密存储过程的存储过程 查询指定的字段所在的表
如何去掉DataTable中的重复行
zzh5945 · 2008-11-20 · via 博客园 - zzh5945

public DataTable GetTopSearch()
        
{
            DataSet dsKeyword 
= dal.GetKeyword();
            DataSet dsTopSearch 
= new DataSet();
            
for (int i = 0; i < 4; i++)
            
{
                
string keyword = dsKeyword.Tables[0].Rows[i]["Name"].ToString();
                
string condition = dsKeyword.Tables[0].Rows[i]["SearchCondition"].ToString();
                dsTopSearch.Merge(dal.GetTopSearch(keyword,condition));
            }

            
return dsTopSearch.Tables[0].DefaultView.ToTable(true"ID","Name","Author","Publisher","PublishDate","TypeName","Price","SalePrice","SavePrice","Rebate","ImagePath","ContentIntro");
        }


先把DataTable转成DataView,再通过DataView.ToTable()转回DataTable,ToTable()方法中有一个重载可以轻松消除重复行.
注:该重载的第二个参数为要保存的字段名.