PC Review


Reply
 
 
Peter Bradley
Guest
Posts: n/a
 
      21st May 2004
Hi,

We are creating our first ASP.Net application, using ADO.Net for data
access.

Having taken advice from many sources, we were convinced to use stored
procedures instead of pushing details of our database structures about the
network in SQL queries. This is the advice contained in "Building secure
ASP.Net applications", from Microsoft.

However we find that although ADO.Net took care of concurrency for us when
we used SQL queries, once we moved to stored procedures this was no longer
the case. We are not generating the stored procedures automatically, but
are writing them ourselves, because they need to be quite complex (The user
must be able to enter values in the user interface that are used as a
retrieve profile. A null value means that all values for that field are
acceptable).

Is there any way that concurrency can be ensured whilst using stored
procedures?

Thanks in advance.

Peter Bradley


 
Reply With Quote
 
 
 
 
Mark Miller
Guest
Posts: n/a
 
      21st May 2004
Here are two methods you could use:

CREATE TABLE myTable(
Id INT IDENTITY(1, 1) NOT NULL,
Value VARCHAR(50),
TimeStamp DATETIME
)

--------------------- DateTime stamp----------------------

CREATE PROCEDURE sp_Update
@Id INT,
@Value VARCHAR(50),
@TimeStamp DATETIME
AS

UPDATE myTable SET
Value = @Value
WHERE Id = @Id AND TimeStamp = @TimeStamp

GO

-------------------- First Update Succeeds -------------------

CREATE PROCEDURE sp_Update
@Id INT,
@Value VARCHAR(50),
@OldValue VARCHAR(50)
AS

UPDATE myTable SET
Value = @Value
WHERE Id = @Id AND Value = @OldValue

GO


 
Reply With Quote
 
Peter Bradley
Guest
Posts: n/a
 
      21st May 2004
Thanks Mark.

It's late Friday now here. So I'll look at it Monday, and let you know how
we get ong

Cheers

Peter

"Mark Miller" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Here are two methods you could use:
>
> CREATE TABLE myTable(
> Id INT IDENTITY(1, 1) NOT NULL,
> Value VARCHAR(50),
> TimeStamp DATETIME
> )
>
> --------------------- DateTime stamp----------------------
>
> CREATE PROCEDURE sp_Update
> @Id INT,
> @Value VARCHAR(50),
> @TimeStamp DATETIME
> AS
>
> UPDATE myTable SET
> Value = @Value
> WHERE Id = @Id AND TimeStamp = @TimeStamp
>
> GO
>
> -------------------- First Update Succeeds -------------------
>
> CREATE PROCEDURE sp_Update
> @Id INT,
> @Value VARCHAR(50),
> @OldValue VARCHAR(50)
> AS
>
> UPDATE myTable SET
> Value = @Value
> WHERE Id = @Id AND Value = @OldValue
>
> GO
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Concurrency Help Jonathan Wood Microsoft ADO .NET 6 22nd May 2008 07:33 AM
Concurrency desais@gmail.com Microsoft Outlook Calendar 1 28th Feb 2006 06:07 PM
Concurrency Help epigram Microsoft ADO .NET 6 17th May 2005 08:05 AM
ADO.NET concurrency =?Utf-8?B?RWQgQ3VycmVu?= Microsoft ADO .NET 2 24th May 2004 08:11 PM
Concurrency in ADO.NET =?Utf-8?B?b3R0bw==?= Microsoft ADO .NET 3 14th May 2004 09:12 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:48 PM.