Link to home
Start Free TrialLog in
Avatar of andre72
andre72

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of andre72
andre72

ASKER

Thanks for your support