Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This My code:
C#
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;
                      
                    }
                }
Posted
Updated 15-Apr-15 6:20am
v2
Comments
Maciej Los 15-Apr-15 12:22pm    
Sorry, but we do not see your screen and we can;t read in your mind. You have to be more specific and provide more details, such as: does that issue occurs on sql server side - at least.

1 solution

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!
 
Share this answer
 
Comments
Member 11280947 15-Apr-15 12:22pm    
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 join StoresTBL as st on st.Store_id=iph.FK_Store_id join InvoicePurchaseDetails as ipd on ipd.FK_Customers_id=iph.FK_Customers_id join Products_TBL as pt on pt.Product_id=ipd.FK_Product_id WHERE ipd.FK_Product_id = 1 and iph.Invoice_Date = DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 0)



This my Code Sql also Duplicated result Wahy
Member 11280947 15-Apr-15 12:24pm    
I have Tow Invoices
one in 2015-04-15
Second 2015-04-01



it Gives my Tow 2015-04-15 Way
sudevsu 15-Apr-15 12:58pm    
use distinct in your query and check
Member 11280947 15-Apr-15 13:46pm    
Thank You
sudevsu 15-Apr-15 14:05pm    
Did that solve your issue?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900