Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Conversion failed when converting date and/or time from character string
    text
    copied!<p>I have googled for the last few hours and none of those questions can be apply to my case, so hope you guys can help. I have a report application which user can pick a date from the DateTimePicker and the item which has the largest quantity value would be displayed. I use the report viewer control to display the information.</p> <p>Here is the SQL query in my table adapter:</p> <pre><code>SELECT TOP (1) Drink_Name, SUM(Quantity) AS NoDrink, Bill_No, Staff_No, Bill_Date, Bill_Value, Customer_No, Unit_Price, Quantity FROM (SELECT Bill.Bill_No, Bill.Staff_No, Bill.Bill_Date, Bill.Bill_Value, Bill.Customer_No, Bill_Detail.Drink_Name, Bill_Detail.Bill_No AS Expr1, Bill_Detail.Unit_Price, Bill_Detail.Quantity FROM Bill INNER JOIN Bill_Detail ON Bill.Bill_No = Bill_Detail.Bill_No WHERE (Bill.Bill_Date = @Bill_Date) ) AS Temp GROUP BY Drink_Name, Bill_No, Staff_No, Bill_Date, Bill_Value, Customer_No, Unit_Price, Quantity ORDER BY NoDrink DESC </code></pre> <p>And here is the code for generate and load data into report dataset</p> <pre><code>CoffeeShopDataSetTableAdapters.DataTable1TableAdapter adapter = new CoffeeShopDataSetTableAdapters.DataTable1TableAdapter(); CoffeeShopDataSet.DataTable1DataTable table = new CoffeeShopDataSet.DataTable1DataTable(); adapter.FillByMax(table, dateTimePicker1.Value.ToShortDateString()); ReportDataSource maxdatasource = new ReportDataSource("DataSet1form3", (DataTable)table); this.reportViewer1.LocalReport.DataSources.Clear(); this.reportViewer1.LocalReport.DataSources.Add(maxdatasource); this.reportViewer1.LocalReport.Refresh(); this.reportViewer1.RefreshReport(); </code></pre> <p>The problem is I always get this error:</p> <p>"An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll</p> <p>Additional information: Conversion failed when converting date and/or time from character string."</p> <p>When I try the SQL query with the SQL server management 2008, it works just fine, so i think this is the VS problem. Thanks all in advance. Sorry for the bad English</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload