本文介绍了如何在dateTimePicker1之间进行搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 string sqlstr3 = select rnh.ReceiptNote_id,rnh.Customer_id,rnh.Customer_Name,rnh.Receipt_Type,rnd.Product_Id,rnd.Product_name ,rnd。数量,rnd.Price,rnh.Receipt_Date来自Receipt_NoteDetalisTBL作为rnd 内部联接Receipt_NoteHeadTBL作为rnh on rnh.ReceiptNote_id = rnd.Fk_ReceiptNote_id 内部联接StoresTBL as st on st。 Store_id = rnh.Store_id 内部联接Products_TBL作为pt on pt.Product_id = rnd.Product_Id WHERE rnd.Product_Id = @Product_Id和rnh.Receipt_Date @ dateTimePicker1.Value.ToString(yyyy-MM-dd) 和@ dateTimePicker1.Value.ToString(yyyy-MM-dd ); 使用(SqlDataAdapter dr3 = new SqlDataAdapter(sqlstr3,CS)) { dr3.SelectCommand.Parameters.AddWithValue(@ Product_Id,txtProductId.Text); dr3.Fill(dt3); dataGridView1。 DataSource = dt3; } 解决方案 尝试: ... WHERE rnd.Product_Id = @Product_Id 和 rnh.Receipt_Date @ DT1 AND @ DT2 ; 使用(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); 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;} 解决方案 Try:... 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); 这篇关于如何在dateTimePicker1之间进行搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-03 11:46