|
| Formula can't act as SQL Sorting Field |
 |
Thu, 20 Mar 2008 15:59:19 +000 |
Hi, I'm modifying a program which access data from MS Access. I tried to use the
"IIf.." (iif is a function in ms access anyway) as one of the fields
for sorting, followed by some standard fields named date_time, date_time_end
here: private string[] SortFieldsNames = new string[] {
"(IIf(Hour([date_time])=14,0,1),2)), date_time, date_time_end" }; ....
Select.OrderBy =
(SortDir==SortDirections.Asc?SortFieldsNames[(int)SortField]:SortFieldsNamesDesc
[(int)SortField]).Trim(); by injecting the above to the sql statement's sql
orderby portion, the query runs w/o error. problem is: it doesn't owner the
value returned by the iif formula (*based on different field values, the formula
should return 0, 1 or 2 which is simply used for sorting purpose here). I find
the formula part doesn't work. The sorting works by sorting the date_time field
then the date_time_end field but no effect seen from the 1st formula. is it a
must that a standard field name (not formula) can be used as SortField for SQL
statement within C# page? thanks, jackling
|
| Post Reply
|
|
|
|
|
|
|
|
|
|