BlakeMcKenna
asked on
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
you may want to add a new column year whicch will be year of dateOfTran and then filter based on that