HighTechTalks DotNet Forums  

Update and Select in the same statement?

Dotnet Framework (ADO.net) microsoft.public.dotnet.framework.adonet


Discuss Update and Select in the same statement? in the Dotnet Framework (ADO.net) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Terry Olsen
 
Posts: n/a

Default Update and Select in the same statement? - 07-30-2007 , 10:36 PM






Is there any way to select a record and update a field in that record in the
same statement? I have a table that several threads will be querying. Once
the record has been selected by a thread, I don't want that record to be
selected by any of the other threads. So my thought was to have a "busy"
column that would be flagged true during the select. However, I don't see a
way to do it.

I'm working with an MDB file so I don't think triggers would be the answer
here. Suggestions anyone?



Reply With Quote
  #2  
Old   
Petar Atanasov
 
Posts: n/a

Default Re: Update and Select in the same statement? - 07-31-2007 , 10:48 AM






Terry Olsen wrote:
Quote:
Is there any way to select a record and update a field in that record in the
same statement? I have a table that several threads will be querying. Once
the record has been selected by a thread, I don't want that record to be
selected by any of the other threads. So my thought was to have a "busy"
column that would be flagged true during the select. However, I don't see a
way to do it.

I'm working with an MDB file so I don't think triggers would be the answer
here. Suggestions anyone?


Hi Terry,
Use row-level locking (I suppose you use OLEDB):
http://msdn2.microsoft.com/en-us/lib...ionstring.aspx

In AD0.NET you can change the locking behaviour to pessimistic through
the IsolationLevel. [http://msdn2.microsoft.com/en-us/library/ms971557.aspx]

In addition you may consider using transactions.

Locks can be set at row, page and database level. Keep in mind that
since Jet 4.0 if row locks reach certain level [as defined in
PagesLockedToTableLock found under the
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engi nes\Jet 4.0], these
locks will be automatically promoted up to page or table level.

HTH,
Petar Atanasov
http://www.a-wake.net


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.