Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB Databases
|
Pro VB Databases Advanced-level VB coding questions specific to using VB with databases. Beginning-level questions or issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 20th, 2003, 07:07 PM
Registered User
 
Join Date: Nov 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Table locked after ADO BeginTrans ?

After a BeginTrans (with ADO 2.7 / SQL Server 7), and an operation (edit, add, or delete) on a table, any other user can even open that table until the CommitTrans or RollbackTrans.
They get a time-out error.

As the user that started the transaction, commits or rolls back, the other users can finally view the results of their pending queries.

I would like not to lock ALL the table during a transaction.
Is this possibile?

Many thanks in advance.
 
Old November 20th, 2003, 07:27 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jlick
Default

Yes, No, Maybe...

I am more familiar for MS-SQL 2000, but I would guess that 7 is similar or the same.

You can give locking hints to SQL Server.

e.g.

  UPDATE myTable WITH (ROWLOCK)
or
  UPDATE myTable WITH (PAGELOCK)

SQL Server goes into detail on locking hints.

Here is the trick. If too many rows are affected, it will lock the table anyway. Also if you suggest a rowlock, it has been my experience that SQL Server will jump to a tablelock, even if all the affected rows are in one page, so you really want to know the size of what you are updating before determining which lock to use.

The best thing to do if you havn't already, is to make sure your transaction is fast. Don't start it until you need it, and commit or rollback ASAP.


John R Lick
[email protected]





Similar Threads
Thread Thread Starter Forum Replies Last Post
ADO recordset to table kanoorani VB Databases Basics 3 May 16th, 2006 02:59 AM
Create table from another table using ADO Kaustav Pro VB Databases 0 October 15th, 2005 05:44 AM
How to Get Table Names in ASP using ADO ramk_1978 ADO.NET 2 October 26th, 2004 03:31 PM
How to Retrieve Table Names using ADO ramk_1978 ADO.NET 1 October 22nd, 2004 08:19 AM
ADO + Open Table tjs206 Access 2 February 3rd, 2004 12:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.