根据datetimepicker中的值显示数据库中的数据

时间:2017-01-30 11:53:43

标签: c# sql-server winforms visual-studio

我有一个结算明细表,其中包含所有销售详情。我有一个账单日期列,它从datetimepicker获取值。帐单日期列的类型为datetime。我想根据datetimepicker中的日期显示数据。我试图通过使用datetime选择器的值更改事件来获取详细信息。但我无法获得价值。

下面是我的代码,

 DateTime Date = dateTimePicker_CustomerCustomerReports.Value;
                string CS = "data source=.; database=BillingSoftware; user id=sa; Password=9495640";
                SqlConnection con = new SqlConnection(CS);
                con.Open();
                SqlDataAdapter da = new SqlDataAdapter("SELECT 
                                                            Bill_Date as [Bill Date],
                                                            Name,
                                                            Item,
                                                            Item_Code as [Item Code],
                                                            MRP, 
                                                            Quantity,
                                                            Amount as Total, 
                                                            Amount_After_Discount as [Grand Total]  
                                                        From POS  LEFT JOIN Customers 
                                                        ON POS.Customer=Customers.Customer_Id 
                                                        WHERE Customer_Id>=1 
                                                        AND Bill_Date Like @BillDate 
                                                        Order by Name", con);
                da.SelectCommand.Parameters.AddWithValue("@BillDate", Date);
                DataTable dt = new DataTable();
                da.Fill(dt);
                dgv_CustomerCustomerReport.DataSource = dt;

0 个答案:

没有答案