Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET databse
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)
 
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 5-Jan-13 10:54am
kosay851.2K
Edited 5-Jan-13 10:57am
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
 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.
  Permalink  

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



Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 6 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100