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

G

Guest

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?
 
G

Guest

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
 
G

Guest

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 said:
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 said:
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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top