So I have this linq code and I am trying to get it to look at the datbase and what it is doing is pulling back the last record put into the database.
My asp page refreshes and displays the new information that was updated.

What I want is to have it so when a row has not been updated in 5 minutes that it turns the textbox red. I know how to do the change the textbox but I do not know how to search if a row was updated in the last 5 minutes or not. I do not want it to check if the textbox has changed or not becuase we use a lot of the same numbers and will read it as not changing.

This is what I have.

var RedLine4Sc1 = (from l in ***.***
                                       where l.**_Port == 4 && l.**_Port == 1 && l.***_Number == 1 && l.Date_Processed >= startDateTime
                                       select l.Date_Processed);

I know this is not correct because it is just seeing if the processed date is == to the time and I was just messing aorund with stuff.

Just tried this because figured it might be better but getting an error. Think it is because it does not see the datetime.

 if (Convert.ToDateTime(RedLine4Sc1) >= redDateTime)

Any help would be appriciative.
Thanks.

Edited 3 Years Ago by Kratoswoo

Add a timer to your form, set the interval to 5 minutes and in the Tick event set the box to red. When you update the value, stop and start the timer to reset the 5 minute interval.

Well I can't do that because the value may stay the same but information in the database in that row will change. We can use the same product ID so textbox won't change but the price or something of that product wll change. So that s why I want to look at the time in database then if it has been 5 minutes to show up.

Decided to go another approuch at it. Decided to take 5 minutes from Datetime.Now. ANyone know how to do that? I keep getting timespan errors.

Want to do something like this.

 DateTime growl = startDateTime - 5 minutes;
                    if (RedLine4Sc1 <= growl)
                    {
                        Line4Scale1.BackColor = System.Drawing.Color.Red;
                    }

Got it to work

 if (RedLine4Sc1 <= fiveDateTime)
                    {
                        Line4Scale1.BackColor = System.Drawing.Color.Red;
                    }

DateTime fiveDateTime = DateTime.Now.AddMinutes(-5).AddHours(1);

Edited 3 Years Ago by Kratoswoo

This question has already been answered. Start a new discussion instead.