0

Currently I have a button, 2 datetimepickers, a datagridview, and a combobox. What I like to do is the user will select the FromDate and ToDate and then with a keyword from a combobox it will search in a datagridivew according to the date range and the combobox's value.

I already implemented a search function for the combobox in the button click event:

 Dim con As New OleDbConnection(Get_Constring)
 Dim dt As New DataTable
 con.Open()
 Dim da As New OleDbDataAdapter("SELECT * from EncodingComplete where Client like '" & ComboBox1.Text & "%'", con)
 da.Fill(dt)
 DataGridView1.DataSource = dt
 con.Close()

How would I code the date range?

2
Contributors
2
Replies
15
Views
2 Years
Discussion Span
Last Post by CodingSource
0

Hi

Do you want to include the DateRange within your SQL statement? If so, you could use the BETWEEN operator, for example:

SELECT * FROM EncodingComplete WHERE YourDateField BETWEEN #01/01/2010# AND #01/01/2011#

Note, depending on the database you are using you may need to substitue the # character with a ' character. I believe Access uses # and SQL Server uses ' but may be wrong.

HTH

0

I don't include that in my SQL statement. Let me try then I will inform you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.