Hi, I'm just confuse about this.. I am making a form with 2 datetimepicker controls which are the Start and End date and when I click the action button it displays all the departments covered with the start-end date and it works fine but the problem is it loads all departments even if there are equal values like this image Click Here What I want is if there are 3 rows with same values it should be 1 row only but I don't have any idea on coding that.
Here's my code:
Try Using conn As New OleDbConnection("Provider = Microsoft.Jet.Oledb.4.0; Data source =" & MyConString & ";Jet OLEDB:Database Password=mydbdatapass;") conn.Open() Dim DateStart As String = ConversionHelper1.ConvertDateToYMD(DStart.Value) Dim DateEnd As String = ConversionHelper1.ConvertDateToYMD(DEnd.Value) Dim command As New OleDbCommand("Select Dept From SoldItems Where SalesDate >= @StartDate And SalesDate <= @EndDate", conn) With command.Parameters .AddWithValue("@StartDate", DateStart) .AddWithValue("@EndDate", DateEnd) End With Dim da As New OleDbDataAdapter Dim dt As New DataTable da.SelectCommand = command da.Fill(dt) DataGridView1.DataSource = dt End Using Catch ex As Exception MsgBox(ex.ToString) End Try
Edited by Reverend Jim: typo in title