?
Solved

Using BindingSource Filters and Date Values

Posted on 2009-06-28
4
Medium Priority
?
752 Views
Last Modified: 2012-08-14
Hi, I'm using VB 2005, WinForms. I have a BindingSourse set to a DataGridView on one of my Forms. I've been able to filter within the DataGridView without a problem, except for DATE values.
I keep getting the following error message when I try to filter for the presence of a date within a column.

ERROR MESSAGE:
----------------------
An unhandled exception of type 'System.Data.EvaluateException' occurred in System.Data.dll
Additional information: Cannot perform '=' operation on System.DateTime and System.String.
---------------------

I've tried coding the filter in the following ways:

bs.Filter = "CanceledDate = ' ' "
bs.Filter = "CanceledDate = 'dbNull.Value'"

Neither seems to work.

I simply need to know if a Date value is present in the cell or if the cell is empty. If there is no Date present, then the item has not been canceled. If there is a Date value present in the cell, then the item was indeed canceled.

This is a syntax problem, but I can't seem to get it right.

Thanks for your help,
Fulano
0
Comment
Question by:Mr_Fulano
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
paisleym earned 2000 total points
ID: 24733811
Hi

Try

Canceled Date is null

hth
Marcelle
0
 

Author Comment

by:Mr_Fulano
ID: 24733838
Hi Marcelle, this is the error I got with the following line of code:

bs.Filter = "Canceled Date is null"

An unhandled exception of type 'System.Data.SyntaxErrorException' occurred in System.Data.dll

Additional information: Syntax error: Missing operand after 'Date' operator.

Any thoughts?

Thanks,
Fulano
0
 

Author Comment

by:Mr_Fulano
ID: 24733842
Hi Marcelle, I fixed it...it should have been:

bs.Filter = "CanceledDate is null"  

Not

bs.Filter = "Canceled Date is null"

That worked!

Thanks!
0
 
LVL 4

Expert Comment

by:paisleym
ID: 24733843
Hi

Is Canceled Date the name of the field? If there is spaces in the field name that can cause errors. Yes, the 'is null' clause is more commonly used within the where clause of an sql query than in a filter, but if the date is sorted it may work. If Canceled Date contains a space it should be '  [Canceled Date] is null'

hth
Marcelle
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question