使用tableAdapter更新sql和vb.net中的最后一条记录

使用tableAdapter更新sql和vb.net中的最后一条记录,sql,vb.net,Sql,Vb.net,我有那张桌子:进出 以及列id exitHour 我想这样做: update exitAndEnter set exitHour=? where id=? AND (exitHour=LAST(exitHour) from enterAndExit) 我希望exitHour仅在它是请求id中的最后一条记录时更新 我希望我正确地解释了我自己我假设id字段是自动递增的,如果id是max或last记录,exitHour将被更新 update exitAndEnter

我有那张桌子:进出 以及列id exitHour

我想这样做:

    update exitAndEnter
    set  exitHour=?
    where id=? AND (exitHour=LAST(exitHour) from enterAndExit)
我希望exitHour仅在它是请求id中的最后一条记录时更新


我希望我正确地解释了我自己

我假设id字段是自动递增的,如果id是max或last记录,exitHour将被更新

update exitAndEnter
    set  exitHour=?
    where exitHour in(select max(exitHour) from exitAndEnter where id=?)

不,id不是自动递增的,它是在系统中登录的每个用户的id。我希望应用程序只更新该用户的最后一条记录,而不是他多次登录和注销的所有记录。我是否应该构建另一个自动递增的列并使用它?好的,我有一个在Access中可用但在VB.NET中不可用的列:update entrandexit SET exitHour=?其中index inselect MAXDINDEX from enterAndExit,其中id=?;