I am trying to create a Crystal Report where I can search between two dates selected by datetimepicker1 and datetimepicker2. MySql database date column has saved datetime like this (12/26/2018 3:28:30 PM). my select statement and parameters are not correct. How can I do this?
Private Function GetData() As billing
Dim x = Form25.DateTimePicker1.Value.Date.ToString("MM-dd-yyyy")
Dim y = Form25.DateTimePicker2.Value.Date.ToString("MM-dd-yyyy")
Dim constr As String = ("server= PANKAJ\SQLEXPRESS; database = pankaj billing software; integrated security=True")
Using con As New SqlConnection(constr)
Using cmd As New SqlCommand("select goldrate,date,itemcode,karat,category,item,qty,grossweight,netweight,discountrs,finalamount from allsaledata where date >= @date AND date <= @date", con)
cmd.Parameters.AddWithValue("@date", x And y)
Using sda As New SqlDataAdapter()
cmd.Connection = con
sda.SelectCommand = cmd
Using dsCustomers As New billing()
sda.Fill(dsCustomers, "DataTable1")
Return dsCustomers
End Using
End Using
End Using
End Using
End Function