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

Access Sql Date Vb


I added a dateDiff to my sql statement:
dateDiff('d', recevDateBillSent, NOW()) AS DiffDate

Open in new window

My dataset is binding to my datagridview, this date difference field has been added as an extra column in my datagridview, but when I try to update other columns in my dataset there is a Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.

I'm guessing it is because vb.net is trying to save the dateDiff column in to my database but there is no column to save to because it is created through the sql statement.

Is there a way around this?
1 Solution
You can use templates for your update/edit that excludes the calculated value from your update command.
FCapoAuthor Commented:
I'm basically trying to filter only the records where a date is either smaller or equal then itself - 7 days.

for example :

recAccessBindingsource.Filter = "recevDateBillSent <= '%recevDateBillSent - 7%'"

but obviously this doesn't work, would there be a way to do this without using SQL?
Alan WarrenCommented:
Sql would be the place to apply the filter:
SELECT Table1.* FROM Table1 WHERE ((DateDiff("d",[The_Date_Field],Date())<=7));

Open in new window

You will need to generate the Update command of adapter manually.


Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

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