Problem with optimistic concurency - What's going on here?

Discussion in 'ASP .Net' started by =?Utf-8?B?Qi4gQ2hlcm5pY2s=?=, Nov 15, 2007.

  1. Ok, I'm out of practice in web work, I've never done any webwork in 2.0, and
    I have to come up with a VB/Dot Net 2.0 web site in a week or two. Business
    as usual.

    First, I know I can't trust Visual Studio to create the correct Update
    statement so every update string has to manually updated. I have a table
    with a timestamp field and I'm trying to make it work. Here is the current
    update statement:
    UPDATE tblProject SET RK_Unit = @RK_Unit, RK_PG = @RK_PG, ID = @ID, Name
    = @Name, [Desc] = @Desc, RK_Class = @RK_Class, G0 = @G0, Notes = @Notes
    WHERE (PK = @PK) AND (@IsNull_upsize_ts = 1) AND (upsize_ts IS NULL) OR
    (PK = @PK) AND (upsize_ts = @upsize_ts)

    When I try to do an update from a bound DetailsView, I get this error: Value
    cannot be null. Parameter name: IsNull_upsize_ts

    So far as I can remember, I have not changed anything relating to logic
    involving the timestamp or this @IsNull parameter. I'm really not clear
    what's going on here or exactly what the @IsNull parameter's purpose is.
    (Haven't dealt with timestamps for a while either.)

    Could someone please explain this?
     
    =?Utf-8?B?Qi4gQ2hlcm5pY2s=?=, Nov 15, 2007
    #1
    1. Advertising

  2. Well, a timestamp is just a self-updating column type that changes when
    anything in the row changes. So this is compared with the timestamp value
    that came back with the data you are editing, and if they are different, that
    means somebody else updated the row while you were "working on it". But, have
    no idea how you got "(@IsNull_upsize_ts " - that's a parameter. More likely
    the SQL would be like
    "IsNull(@upsize_ts)" - IsNull should be returning bool. You probably need
    to post more code to clarify.

    --Peter
    "Inside every large program, there is a small program trying to get out."
    http://www.eggheadcafe.com
    http://petesbloggerama.blogspot.com
    http://www.blogmetafinder.com



    "B. Chernick" wrote:

    > Ok, I'm out of practice in web work, I've never done any webwork in 2.0, and
    > I have to come up with a VB/Dot Net 2.0 web site in a week or two. Business
    > as usual.
    >
    > First, I know I can't trust Visual Studio to create the correct Update
    > statement so every update string has to manually updated. I have a table
    > with a timestamp field and I'm trying to make it work. Here is the current
    > update statement:
    > UPDATE tblProject SET RK_Unit = @RK_Unit, RK_PG = @RK_PG, ID = @ID, Name
    > = @Name, [Desc] = @Desc, RK_Class = @RK_Class, G0 = @G0, Notes = @Notes
    > WHERE (PK = @PK) AND (@IsNull_upsize_ts = 1) AND (upsize_ts IS NULL) OR
    > (PK = @PK) AND (upsize_ts = @upsize_ts)
    >
    > When I try to do an update from a bound DetailsView, I get this error: Value
    > cannot be null. Parameter name: IsNull_upsize_ts
    >
    > So far as I can remember, I have not changed anything relating to logic
    > involving the timestamp or this @IsNull parameter. I'm really not clear
    > what's going on here or exactly what the @IsNull parameter's purpose is.
    > (Haven't dealt with timestamps for a while either.)
    >
    > Could someone please explain this?
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Nov 15, 2007
    #2
    1. Advertising

  3. That's kind of a problem. There's very little code to post. I'm trying to
    write this web site, at least for now, by relying on VS and ASP's built in
    tools and defaults. (That "(@IsNull_upsize_ts" was generated by Visual
    Studio, hence my confusion.) I've bound controls and when I try to use this
    update script, it crashes. If I cut out all references to the timestamp,
    update works fine. For prototyping this does not matter, but it probably
    would be good form to get this working in the long run. (I'll worry about it
    after Thanksgiving.)

    Thanks.

    "Peter Bromberg [C# MVP]" wrote:

    > Well, a timestamp is just a self-updating column type that changes when
    > anything in the row changes. So this is compared with the timestamp value
    > that came back with the data you are editing, and if they are different, that
    > means somebody else updated the row while you were "working on it". But, have
    > no idea how you got "(@IsNull_upsize_ts " - that's a parameter. More likely
    > the SQL would be like
    > "IsNull(@upsize_ts)" - IsNull should be returning bool. You probably need
    > to post more code to clarify.
    >
    > --Peter
    > "Inside every large program, there is a small program trying to get out."
    > http://www.eggheadcafe.com
    > http://petesbloggerama.blogspot.com
    > http://www.blogmetafinder.com
    >
    >
    >
    > "B. Chernick" wrote:
    >
    > > Ok, I'm out of practice in web work, I've never done any webwork in 2.0, and
    > > I have to come up with a VB/Dot Net 2.0 web site in a week or two. Business
    > > as usual.
    > >
    > > First, I know I can't trust Visual Studio to create the correct Update
    > > statement so every update string has to manually updated. I have a table
    > > with a timestamp field and I'm trying to make it work. Here is the current
    > > update statement:
    > > UPDATE tblProject SET RK_Unit = @RK_Unit, RK_PG = @RK_PG, ID = @ID, Name
    > > = @Name, [Desc] = @Desc, RK_Class = @RK_Class, G0 = @G0, Notes = @Notes
    > > WHERE (PK = @PK) AND (@IsNull_upsize_ts = 1) AND (upsize_ts IS NULL) OR
    > > (PK = @PK) AND (upsize_ts = @upsize_ts)
    > >
    > > When I try to do an update from a bound DetailsView, I get this error: Value
    > > cannot be null. Parameter name: IsNull_upsize_ts
    > >
    > > So far as I can remember, I have not changed anything relating to logic
    > > involving the timestamp or this @IsNull parameter. I'm really not clear
    > > what's going on here or exactly what the @IsNull parameter's purpose is.
    > > (Haven't dealt with timestamps for a while either.)
    > >
    > > Could someone please explain this?
     
    =?Utf-8?B?Qi4gQ2hlcm5pY2s=?=, Nov 16, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TWlrZSBLZWxseQ==?=

    Optimistic concurrency in custom GridView/SqlDataSource

    =?Utf-8?B?TWlrZSBLZWxseQ==?=, Nov 10, 2005, in forum: ASP .Net
    Replies:
    8
    Views:
    2,235
    Jason
    Jan 4, 2006
  2. Replies:
    2
    Views:
    613
  3. TonY
    Replies:
    0
    Views:
    331
  4. Replies:
    0
    Views:
    533
  5. Andrew Robinson

    Optimistic Concurrency in a web app

    Andrew Robinson, Jan 31, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    455
    Steven Cheng[MSFT]
    Feb 5, 2007
Loading...

Share This Page