Updatecommand
- From: "Sam" <sam@xxxxxxxxxx>
- Date: Sat, 29 Oct 2005 15:12:37 -0400
I have a trigger that runs when updating time related data. And to not
allow duplicate entries for a specific date it does the following:
.....
IF @cntoverlappingrows > 0
BEGIN
RAISERROR( 'The new date entry falls into a previous interval.', 16, 1)
ROLLBACK TRANSACTION
RETURN
END
This works great with the following code to show the user where the error
occured by posting that red warning icon:
if (e.Status == UpdateStatus.ErrorsOccurred)
{
e.Row.RowError = e.Errors.Message;
e.Status = UpdateStatus.SkipCurrentRow;
}
else
{
if (e.StatementType == StatementType.Insert)
{
e.Status = UpdateStatus.SkipCurrentRow;
}
}
However the hair pulling begins when I get an error on the insert caused by
the first code section above. But if the user goes back and tries to fix the
error ( the error means we still are trying to insert the new record ) and
click save we get a "concurrency violation: updatecommand ...." error. I
understand why we get the concurrency violation. ADO is trying to update
the entry which was meant to be an insert since it never passed the trigger
which rejects the insert. We are not getting a primary key back because we
still haven't inserted yet. Why is ADO trying to update something that was
never inserted. Does anyone know how to get this record to show up as an
insert? How I can refresh/reload the dataset which does not contain the row
with that insert error? Basically my insert is stuck and can not be updated.
Please help me make my insert an insert!!
By the way if I click refresh obviously the correct data shows again. If I
can't get the insert to be an insert rather than an update I would be open
to any suggestions on handling this.
Thanks to anyone ahead of time. I hope I have some hair left.
.
- Prev by Date: Re: newbie needs help with a web service for infopath
- Next by Date: Re: Optimizing LIKE in SQL statements
- Previous by thread: How to find in DataView if the primarykey more than one
- Next by thread: Re: Optimizing LIKE in SQL statements
- Index(es):
Relevant Pages
|
Loading