Access Sql Date Vb

Hi,

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?
FCapoAsked:
Who is Participating?
 
CodeCruiserCommented:
You will need to generate the Update command of adapter manually.

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.updatecommand.aspx
0
 
Jared_SCommented:
You can use templates for your update/edit that excludes the calculated value from your update command.
0
 
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?
0
 
Alan WarrenApplications DeveloperCommented:
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

Alan
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.