Re: Concurrencty violation with decimal type

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: William \(Bill\) Vaughn (billvaRemoveThis_at_nwlink.com)
Date: 03/20/04


Date: Fri, 19 Mar 2004 20:14:34 -0800

Ok, what backend are you using? The double quotes look problematic for SQL
Server unless you have quoted identifiers enabled. I'm not so sure you're
saving any time using the CB and your cleanup approach.

-- 
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
"hb" <hbranyan.SPAMBLOCK@merc.mercer.edu> wrote in message
news:c3caat$26uqi2$1@ID-92475.news.uni-berlin.de...
> "William (Bill) Vaughn" <billvaRemoveThis@nwlink.com> wrote in message
> news:uKEt8sJDEHA.576@TK2MSFTNGP11.phx.gbl...
> > It would  be useful to see the UPDATE statement you're executing. If
it's
> > generated by the CommandBuilder or one of the drag-and-drop or
DataAdapter
> > Configuration wizard it could  be that one of the columns don't match. I
> > think this approach is pretty (fill in your own adjective). I suggest
> using
> > a simpler approach--put a TimeStamp column in your table and use it to
> > determine if there are collisions. It's faster and easier to debug.
>
> Thank you for the reply, Bill.  You are the first and only so far out of
all
> the ngs and forums I've asked.
>
> The Update statement is generated by the CommandBuilder.  Since the table
> being updated contains almost 100 columns (designed by previous contractor
> on project, ugh), we thought the CommandBuilder would be the way to go.
>
> We do a bit of massaging before the update executes.
>
> First, we call
> protected void CleanTableForUpdating() {
>   ArrayList colStrings = new ArrayList();
>   foreach (DataColumn col in requestDataTable.Columns)   {
>     String colName = col.ColumnName.ToLower();
>      if (colName != "control_yr" && colName != "control_nr"
>           && requestDataTable.Rows[0][colName,
> DataRowVersion.Original].Equals(requestDataTable.Rows[0][colName,
> DataRowVersion.Current])) {
>         colStrings.Add( colName );
>      }
>    }
>    foreach ( string column in colStrings ) {
>      requestDataTable.Columns.Remove( column );
>    }
> }
>
> Note: Control_Yr and Control_Nr are the primary key of the table.  We
remove
> any other columns that have not been changed from the table, so the update
> only affects the changed columns.  We did this to make, as you said,
> debugging easier.  After CleanTableForUpdating(), the Update() is called
on
> the data adapter.
>
> Then we do a bit of tracing in the RowUpdating handler.
> public void daUpdatingHandler( object sender, OracleRowUpdatingEventArgs
e)
> {
>   HttpContext.Current.Trace.Write( "Row_Updating",
e.Command.CommandText );
>   foreach( OracleParameter oraParam in e.Command.Parameters ) {
>     HttpContext.Current.Trace.Write( oraParam.SourceColumn,
> oraParam.Value.ToString() );
>   }
> }
>
> This outputs the statement and the columns/values.
> Here is an example statement:
> UPDATE "TECHNICAL_ASSISTANCE_REQUESTS" SET "CRRNT_ARFRM_HRS"=:1 WHERE
> "CONTROL_NR"=:2 AND "CONTROL_YR"=:3 AND "CRRNT_ARFRM_HRS"=:4
>
> The columns/values are:
>
> CRRNT_ARFRM_HRS 3088.3
> CONTROL_NR 329
> CONTROL_YR 2004
> CRRNT_ARFRM_HRS 3088.6
>
> So, if I take this statement and merge in the values, I have:
> UPDATE TECHNICAL_ASSISTANCE_REQUESTS SET CRRNT_ARFRM_HRS = 3088.3 WHERE
> CONTROL_NR = 329 AND CONTROL_YR = 2004 AND CRRNT_ARFRM_HRS = 3088.6
>
> I then login via TOAD and execute the statement.  No problem.  However,
the
> statement fails in code and gives the concurrency violation error.
>
> I have changed the variables I store CRRNT_ARFRM_HRS from decimal to
double,
> and I still get the same error.  I think today I will try to just store it
> as a string, since I don't think the values will be used for any
> calculations.
>
> If you have further suggestions, other than rewriting my entire class, I
> look forward to them.
>
> Hillarie
>
>
> > "hb" <hbranyan.SPAMBLOCK@merc.mercer.edu> wrote in message
> > news:c3ach3$25i546$1@ID-92475.news.uni-berlin.de...
> > > Situation:
> > >
> > > Using a dataset's UpdateCommand, when a decimal type field changes
from
> > > integer to decimal, the update goes through. When the field changes
from
> > > decimal to integer or another decimal, I get a Concurrency violation:
> the
> > > UpdateCommand affected 0 records error.
> > >
> > > I have used trace to view the CommandText and all the source columns
and
> > > parameters. When I try to execute the update statement directly in the
> > > database, the record updates. Just a code issue, apparently. I noticed
> in
> > a
> > > search of these forums someone else had a similar problem, and they
> solved
> > > it, but never posted their fix.
> > >
> > > Any suggestions? using .NET 1.0 framework w/ ODP.NET data provider.
>
>


Relevant Pages

  • Re: Concurrencty violation with decimal type
    ... The Update statement is generated by the CommandBuilder. ... I then login via TOAD and execute the statement. ... I have changed the variables I store CRRNT_ARFRM_HRS from decimal to double, ... when a decimal type field changes from ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Best way to store postfix data?
    ... with control logic in the same time as the old read one line, execute ... but there's some memory hog I've missed in there. ... that seems infinitely preferable to trying to store them inline ... Since I allow control routines, I have to execute at runtime, ...
    (microsoft.public.vc.mfc)
  • Re: is malloc thread-safe??
    ... Richard Tobin wrote: ... If two separate threads that share the variable both execute the ... it can do the "store", the second thread can load, add, and store, ... C on some systems), an implementation-dependent locking mechanism ...
    (comp.lang.c)
  • Re: Concurrencty violation with decimal type
    ... Bill. ... The Update statement is generated by the CommandBuilder. ... I then login via TOAD and execute the statement. ... when a decimal type field changes from ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: extract values from a csv file
    ... The reason I asked to store the values into ... individual variables, because I need to execute another shell script ... line by line and store the values into variables and then execute the ...
    (comp.unix.shell)