我的dataGridView重复结果Whay [英] My dataGridView Duplicate result Whay

查看:101
本文介绍了我的dataGridView重复结果Whay的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

This My code:

DataTable dt5 = new DataTable();
                string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
                using (SqlConnection con = new SqlConnection(CS))
                {
                    string sqlstr5 = "select ipd.FK_Product_id,pt.Product_name,iph.FK_Store_id ,st.Store_name,iph.Invoice_Date,ipd.QTY,ipd.TotalInvoice from InvoicePurchaseHead as iph inner join StoresTBL as st on st.Store_id=iph.FK_Store_id inner join InvoicePurchaseDetails as ipd on ipd.FK_Customers_id=iph.FK_Customers_id inner join Products_TBL as pt on pt.Product_id=ipd.FK_Product_id WHERE ipd.FK_Product_id = @FK_Product_id  and  iph.Invoice_Date = DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 0)";
                    using (SqlDataAdapter dr7 = new SqlDataAdapter(sqlstr5, CS))
                    {
                        dr7.SelectCommand.Parameters.AddWithValue("@FK_Product_id", txtProductId.Text  );
                        dr7.Fill(dt5);
                        dataGridView1.DataSource = dt5;
                      
                    }
                }

推荐答案

首先查看您的数据。请记住,当匹配时,INNER JOIN会从两个表中返回数据,因此值得查看您正在使用的数据。



当然,我们可以帮助你 - 我们根本无法访问你的数据!
Start by looking at your data. Remember that an INNER JOIN returns the data from both tables when there is a match, so it's worth looking at exactly what data you are working with.

Certainly, we can't help you - we don't have any access to your data at all!


这篇关于我的dataGridView重复结果Whay的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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