Access Sql Date Vb

Posted on 2012-09-11
Last Modified: 2012-09-17

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 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?
Question by:FCapo
    LVL 12

    Expert Comment

    You can use templates for your update/edit that excludes the calculated value from your update command.

    Author Comment

    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?
    LVL 26

    Expert Comment

    by:Alan Warren
    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

    LVL 83

    Accepted Solution

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

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now