Getting Error in BindingSource Filter?

I'm getting an error when I set my BindingSource Filter property to the following string.

                        strFilter = " YEAR(dateOfTran) = " & CInt(Trim(cmbYear.Text)) & " AND MONTH(dateOfTran) = " & GetMonthLiteral(0, cmbMonth.Text)

I get the Error Message:  "The expression contains undefined function call YEAR()". I created a SQL Query that used this string and ran it in SQL Server Management Studio and it ran fine. What am I missing. Here is the actual code below.

                        strFilter = " YEAR(dateOfTran) = " & CInt(Trim(cmbYear.Text)) & " AND MONTH(dateOfTran) = " & GetMonthLiteral(0, cmbMonth.Text)
                    bsTransactions.Filter = strFilter

Here is what the strFilter looks like after I run it through the Debugger:

    YEAR(dateOfTran) = 2013 AND MONTH(dateOfTran) = 8
BlakeMcKennaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gautham JanardhanCommented:
you need to stick to this http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx

you may want to add a new column year whicch will be year of dateOfTran and then filter based on that
0
BlakeMcKennaAuthor Commented:
I already read that MSDN topic. Plus, I did go ahead and add a Year AND a Month column since the query needed both values.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BlakeMcKennaAuthor Commented:
After I looked at the MSDN Topic as well as other posts from various sites, I realized that would probably be my best solution for what I needed.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.