我从2个表中检索数据并在gridview中显示,但是在gridview中,数据r显示但重复如何避免重复项 [英] i retrieve datas from 2 tables and display in gridview but in gridview the datas r displaying but repeating how to avoid the repeating items

查看:113
本文介绍了我从2个表中检索数据并在gridview中显示,但是在gridview中,数据r显示但重复如何避免重复项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的密码
DataSet ds1 =新的DataSet();
ds1 = dbe.getData(选择产品代码,产品名称,类别,批号,数量,包装,购买率,PackMRP,UnitMRP," +
"a.tax,a.reorder_level,a.manufacturer,a.expirydate,a.Commission,a.DSLimit,a.discount,a.Rack,b.taxamt,b.unittax,b.freeqnty,b.master_stock中的金额a,购买b,其中invoiceno =''+ txtInvoiceNo.Text +"''和a.invoiceno = b.billno);
DGProductList.DataSource = ds1.Tables [0];

THIS IS MY CODE
DataSet ds1 = new DataSet();
ds1 = dbe.getData("select a.productcode,a.productname,a.category,a.batchno,a.quantity,a.Packing,a.Purchaserate,a.PackMRP,a.UnitMRP," +
"a.tax,a.reorder_level,a.manufacturer,a.expirydate,a.Commission,a.DSLimit,a.discount,a.rack,b.taxamt,b.unittax,b.freeqnty,b.Amount from master_stock a,purchases b where invoiceno=''" + txtInvoiceNo.Text + "'' and a.invoiceno=b.billno");
DGProductList.DataSource = ds1.Tables[0];

推荐答案

GridView没有问题.它正在显示应该显示的内容.
在SQL查询中使用distinct关键字从数据库中获取不同的记录.
There is no problem with the GridView. It is showing what it is supposed to show.
Use distinct keyword in your sql query to get distinct records from the database.


问题与您用于获取数据的查询有关.
请在您的SQL Server查询设计器中检查/形成SQL查询,检查是否在那里获得了所需的结果,然后使用该查询显示在Gridview中.
Problem is with the query that you are using to fetch the data.
Please check/form the SQL query in your SQL server query designer, check that you ar getting desired result there, then use that query to show in Gridview.


这篇关于我从2个表中检索数据并在gridview中显示,但是在gridview中,数据r显示但重复如何避免重复项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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