Cannot interpret token

J

Jeff

Hey

..NET 2.0

I have a DataTable I'm trying to do a select against... This is the
argument I pass into the Select method:
"date >= 01.12.2007 00:00:00 and date < 01.01.2008 00:00:00"

This argument throws an exception during runtime.. The exception is this:
Cannot interpret token '.' at position 14

any suggestions?
 
M

marss

I have a DataTable I'm trying to do a select against... This is the
argument I pass into the Select method:
"date >= 01.12.2007 00:00:00 and date < 01.01.2008 00:00:00"

This argument throws an exception during runtime.. The exception is this:
Cannot interpret token '.' at position 14

any suggestions?

Look here for the valid syntax of select expressions:
http://msdn2.microsoft.com/en-us/library/system.data.datacolumn.expression(VS.71).aspx

Regards,
Mykola
http://marss.co.ua
 
L

Lasse Vågsæther Karlsen

Jeff said:
Hey

.NET 2.0

I have a DataTable I'm trying to do a select against... This is the
argument I pass into the Select method:
"date >= 01.12.2007 00:00:00 and date < 01.01.2008 00:00:00"

This argument throws an exception during runtime.. The exception is this:
Cannot interpret token '.' at position 14

any suggestions?

Not having used that syntax for querying a data table, I would assume it
would need to delimit the date/time value from the rest of the
expression, perhaps like this:

"date >= '01.12.2007 00:00:00' and date < '01.01.2008 00:00:00'"
 
J

Jon Skeet [C# MVP]

.NET 2.0

I have a DataTable I'm trying to do a select against... This is the
argument I pass into the Select method:
"date >= 01.12.2007 00:00:00 and date < 01.01.2008 00:00:00"

This argument throws an exception during runtime.. The exception is this:
Cannot interpret token '.' at position 14

any suggestions?

The MSDN documentation around DataColumn.Expression suggests that
dates should be enclosed in quotes or # signs. Worth trying...

Personally I really hate the whole idea of DataTable.Select - it's
very culture-specific, completely unchecked at compile-time etc... it
should have been delegate based from the start, even aside from LINQ.

Jon
 
M

Marc Gravell

Personally I really hate the whole idea of DataTable.Select - [snip]
I'd have stopped at the period ;-p
it should have been delegate based from the start, even aside from LINQ.
To be fair, the functional-programming stuff *mainly* kicked off in
2.0; however, I can't think of a sensible reason that it couldn't have
used tokenised parameters (ala SQL). I guess they just wanted single-
textbox filtering (etc) in the IDE.

I was going to cite IBindingListView.Filter as an example here, but
actually it looks like this interface is 2.0 (where-as
DataTable.Select and DataView.RowFilter are 1.x)... so even less of an
excuse...

Oh well...

Marc
 
J

Jon Skeet [C# MVP]

Personally I really hate the whole idea of DataTable.Select - [snip]

I'd have stopped at the period ;-p
:)
it should have been delegate based from the start, even aside from LINQ.

To be fair, the functional-programming stuff *mainly* kicked off in
2.0; however, I can't think of a sensible reason that it couldn't have
used tokenised parameters (ala SQL). I guess they just wanted single-
textbox filtering (etc) in the IDE.

As an alternative to delegates, a simple interface would have
sufficed. To me, it's crazy to have a way of selecting data which
doesn't let you put your own code in.
I was going to cite IBindingListView.Filter as an example here, but
actually it looks like this interface is 2.0 (where-as
DataTable.Select and DataView.RowFilter are 1.x)... so even less of an
excuse...

:)

Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top