Check the time stored in the DB, then make sure its 15 min later before running a update task
<p>I would like to stop people from constantly syncing/updating items in the DB as this could cause potential problems.  I have a time the last sync/update occured which is stored in the DB.  What I need to do is disable the user from initiating another update/sync until 15 minutes has passed since the last update/sync.</p>

<p>How would i go about doing this?</p>

<p>Update: for some reason i am getting the error "A new expression requires (), [], or {} after type" on DateTime lastUpdate. Any ideas why this could be?</p>

<pre><code> DataDataContext dc = new DataDataContext();

        DateTime lastUpdate = from t in dc.Settings
                              where t.id == 1
                              select t.lastSync;


        if ((DateTime.Now - lastUpdate).TotalMinutes &gt;= 15)
        {

        }
        else { }
</code></pre>

<p>Update: Sorted, i missed off the (); of the datacontext!! <em>facepalm</em></p>

<p>Final Update: All fixed and working! Many thanks for all your help, for the ones who think this "smells fishy" or "is bad" then here is what i did!!</p>

<pre><code>DateTime lastUpdate = (from t in dc.Settings
                               where t.id == 1
                               select t.lastSync).Single();


        if ((DateTime.Now - lastUpdate).TotalMinutes &gt;= 15)
        {
            syncbuttons.Visible = false;
        }
        else { syncbuttons.Visible = true; }
</code></pre>

<p>Now please explain what is so suspect about what i am trying to do? Stopping users from hammering a database? What if i have 30 users attempting to update/sync. Would not be that good would it!</p>
