Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
I need help
I make small program but the problem in filter data in datagridview
I use databinding with datetimepacker (I need data between tow dates)

VB
Dim T1 As Date
Dim T2 As Date
T1 = Convert.ToDateTime(Me.DateTimePicker1.Value)
T2 = Convert.ToDateTime(Me.DateTimePicker2.Value)
Me.T1BindingSource.Filter = "_Date >= #T1#  AND _Date <= #T2#"



but there is an error
The string was not recognized as a valid DateTime. There is a unknown word starting at index 0.
can anyone help me ?
Posted
Updated 5-Jan-13 10:57am
v3

1 solution

The string was not recognized as a valid DateTime. There is a unknown word starting at index 0.
To start with, it looks like one of the code lines like
C#
Convert.ToDateTime(Me.DateTimePicker1.Value)

is throwing the same. Based on error, the value is either empty or not in a format that can be converted into a Datetime.
Make sure, you have a valid datetime value for conversion.

Moving ahead, the filter criteria formed should be proper as expected. Use VS DEBUGGER to track and see the workflow and values.
 
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