• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 473
  • Last Modified:

How to modify DataTable rows using Select() or LINQ

Hi,

I've a DataTable with some tasks an starttime and endtime like this:
Action            StartTime      EndTime
Sleep            9:04            9:54
Breakfast              9:54            10:31
Go to work      10:31      11:07

Now I need to modify the rows if I need entries to insert, e.g. shower from 9:41 to 10:08 :

Action            StartTime      EndTime
Sleep            9:04            9:41
Shower           9:41         10:08
Breakfast              10:08      10:31
Go to work      10:31      11:07

Till now I had a MDB as backend so I get the rows by a SQL command like:
SELECT * FROM table WHERE (StartTime BETWEEN NewStartTime AND NewEndTime) OR (EndTime BETWEEN NewStartTime AND NewEndTime)

With the rows returned by the query I do a lot of string operations to compare what I've to change / update / insert and store these results back to my MDB.

The matter is that I've no more a backend so I've to do these operations in memory now...

So would to you think is a way to do so, I tried mydt.Select("(StartTime BETWEEN NewStartTime AND NewEndTime) OR (EndTime BETWEEN NewStartTime AND NewEndTime)") reports an error for BETWEEN so I think I can't use it - or do I something wrong?

Oris there a simple way you use with LinQ?
As I'm a novice with LinQ I may need some useful hints for how to do something like tis ...

Thanks

Andre
0
andre72
Asked:
andre72
2 Solutions
 
CodeCruiserCommented:
Try

mydt.Select("(StartTime >= NewStartTime AND StartTime <= NewEndTime) OR (EndTime >= NewStartTime AND EndTime <= NewEndTime)")
0
 
andre72Author Commented:
Thanks for your support
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now