VB.Net Query Error


I've been creating queries for my program and I ran into an odd error in VB.Net.  What happens is, when I run the program and use the query, the program closes and gives me the following error.  Cannot perform 'Like' operation on System.DateTime and System.String.  What I want for this query to do is allow the user to search dates.  

Lets say I had a record that has the date 5/16/2011.  I want to be able to type 5 into the query and see all the records that contain 5/--/----  and so on.  I believe this is done by using a textchanged property but alas I have that error.

Here is the code I have been using:
Private Sub txtOrder_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtOrder.TextChanged
        If txtOrder.TextLength > 0 Then
            All_flood_certsBindingSource.Filter = String.Format("[Order Received] Like '" & txtOrder.Text) & "'"
            All_flood_certsBindingSource.Filter = String.Empty
        End If
    End Sub

Open in new window

If anyone can shed some light on this issue I would be greatly thankful!
Who is Participating?
Since the datatype is a date, I don't think you can use the LIKE operator.
If you're working on MSSQL you'd have to use DATEPART and (probably) EXTRACT on MySQL.

Of course, you'd also have to validate what part of the date the user is entering (Month, Day or Year) and change the "unit" in function accordingly.

Hope it helps.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.