Click here to Skip to main content
15,881,858 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am using VS2010 and Microsoft Access Database 2013. I have a query to search the action start data. Depending on which date I select on the datetimepicker I get no results or limited results without any error message during application debugging.

My code is below.
VB
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
    
        Dim Search As Date = ActionStartDateDateTimePicker.Value
        Me.ActionsLogTableAdapter.FilterBYActionStartDate(Me.GSKactionsDBDataSet.ActionsLog, Search)

        Form48.MdiParent = Form27
        Form48.Show()
        Form48.ActionsLogTableAdapter.FilterBYActionStartDate(Form48.GSKactionsDBDataSet.ActionsLog, Search)

    End Sub

And my Query is as follows:

Method Name: FilterBYActionStartDate
SQL
SELECT        ID, ActionReferance, ActionDescription, ActionSite, ActionCategory, ActionImportance, ActionAccountability, ActionProgressStatus, ActionClosurestatus, ActionDoneBy,
                         ActionComment, ActionYear, ActionStartDate, PlannedClosureDate, RealClosureDate, ActualClosureDuration, PlannedClosureDuration
FROM            ActionsLog
WHERE        (ActionStartDate LIKE ?)

Thanks for any help.
Posted
Updated 12-Sep-15 7:29am
v3

As far as I can see the problem is that you seem to store the ActionStartDate in a character column. The situation should be corrected by using a datetime column instead and then normal operators such as =, >, < and so on to compare the datetime column with the value from the user interface. LIKE operator is meant to be used when searching with partial data from a string data.

For more information about the data types, see SQL Data Types[^]
 
Share this answer
 
v2
Comments
Maciej Los 12-Sep-15 14:18pm    
+5!
Wendelius 13-Sep-15 1:18am    
Thanks!
Sherif Adely 12-Sep-15 14:21pm    
Hi Mika,
Thank you for your prompt response
I have changed the operators to =, > but I still get no results or limited results
Wendelius 13-Sep-15 0:29am    
As said, it's not enough to change the operator. If the data type of the column is character, you need to change it to datetime.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900