Click here to Skip to main content
15,917,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
string sqlstr3 =
"select rnh.ReceiptNote_id, rnh.Customer_id,rnh.Customer_Name,rnh.Receipt_Type,rnd.Product_Id,rnd.Product_name
,rnd.Quantity,rnd.Price,rnh.Receipt_Date from Receipt_NoteDetalisTBL as rnd
inner join Receipt_NoteHeadTBL as rnh on rnh.ReceiptNote_id=rnd.Fk_ReceiptNote_id
inner join StoresTBL as st on st.Store_id=rnh.Store_id
inner join Products_TBL as pt on pt.Product_id=rnd.Product_Id
WHERE rnd.Product_Id = @Product_Id and rnh.Receipt_Date between

@dateTimePicker1.Value.ToString("yyyy-MM-dd")
and @dateTimePicker1.Value.ToString("yyyy-MM-dd") ";


using (SqlDataAdapter dr3 = new SqlDataAdapter(sqlstr3, CS))
{
dr3.SelectCommand.Parameters.AddWithValue("@Product_Id", txtProductId.Text );
dr3.Fill(dt3);
dataGridView1.DataSource = dt3;
}
Posted
Comments
Richard MacCutchan 26-Apr-15 3:08am    
Don't use strings for dates, use proper DateTime fields.
Member 11280947 26-Apr-15 3:25am    
How

1 solution

Try:
SQL
... WHERE rnd.Product_Id = @Product_Id and rnh.Receipt_Date between @DT1 AND @DT2";

using (SqlDataAdapter dr3 = new SqlDataAdapter(sqlstr3, CS))
{
dr3.SelectCommand.Parameters.AddWithValue("@Product_Id", txtProductId.Text );
dr3.SelectCommand.Parameters.AddWithValue("@DT1", @dateTimePicker1.Value);
dr3.SelectCommand.Parameters.AddWithValue("@DT2", @dateTimePicker1.Value);
 
Share this answer
 
Comments
Member 11280947 26-Apr-15 3:58am    
When Select The day it give me The sacuund day
like if select day 9 it give me 10
How can select specific Day
OriginalGriff 26-Apr-15 4:02am    
Do you want to try explaining that to someone who can't see your screen? :laugh:
Perhaps an example of the data you store, the values you pass, the results you get, and the results you expect?
Member 11280947 26-Apr-15 5:58am    
I don't Understand
Member 11280947 26-Apr-15 6:06am    
WHERE rnd.Product_Id = @Product_Id and rnh.Receipt_Date >= @DT1 AND <= @DT2";
how Can do that
OriginalGriff 26-Apr-15 6:09am    
Either use BETWEEN as in my example, or
WHERE rnd.Product_Id = @Product_Id and rnh.Receipt_Date >= @DT1 AND rnh.Receipt_Date <= @DT2"

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