Wrox Programmer Forums
|
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 August 20th, 2003, 03:56 AM
Authorized User
 
Join Date: Jul 2003
Posts: 40
Thanks: 0
Thanked 1 Time in 1 Post
Default SQL Server

I 've got a problem with concerrency in SQL Server with VB6 Application.
I got a message about 'deadlock' error when some transaction is made at the same time .. How can I prevent this error? there're about 10 users using this application at the same time ..
Thanks

 
Old August 20th, 2003, 04:12 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

You just need to trap the error and retry the operation. Here's the error number to look out for:
Code:
Public Const cErrDeadlock As Long = &H80004005
Public Const cErrTimeout As Long = &H80040E31 ' this is useful too
and here's an example of code to put in an error handler (retries 3 times):
Code:
' retry any deadlocks or lock timeouts
Dim nRetryCount As Integer
If nRetryCount < 3 And (Err.Number = cErrDeadlock Or Err.Number = cErrTimeout) Then
    nRetryCount = nRetryCount + 1
    Resume
Else
    ' handle other errors here
End If
 
Old August 20th, 2003, 11:30 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

You can minimize, (though not necessarily eliminate) deadlocks by doing two things. First, make sure your transactions are as short as possible. Don't start a transaction then hold it open while you are waiting for user input, for example.

Second, insure that you always access objects in the same order. For example, If one procedure consists of:

Begin Transaction
UPDATE OrderItems ...
UPDATE Orders ...
Commit Transaction

and a second process does:

Begin Transaction
UPDATE Orders ...
UPDATE OrderItems ...
Commit Transaction

this will pretty much guarantee a deadlock eventually. If both processes obtain the locks in the same order, then the second will happily wait until the locks are released by the first's commit.

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old August 20th, 2003, 12:07 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

I agree with both of the above responses. I would readup on locking in the SQL Books online. (Help from query analyser.)

You should look at how your transactions are processing. Don't use distributed transactions when you are only updating one table.

Consider using NOLOCK on your select statements. (This allows the select to read uncommitted data, but stops it from locking the table.)

Don't create transactions for multiple select statements unless your really need to.

John R Lick
[email protected]
 
Old August 21st, 2003, 02:05 AM
Authorized User
 
Join Date: Jul 2003
Posts: 40
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thanks for every one to help me solved this problem.

 
Old December 18th, 2004, 01:22 PM
Registered User
 
Join Date: Dec 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Upon starting Windows ME, I recieve the system error &H80004005(-2147767259). unspecified error. When I click Ok on the error message It goes away but windows never starts up past a blueish screen.Can somebody please help me?






Similar Threads
Thread Thread Starter Forum Replies Last Post
Conflict in SQL Server 2000 and SQL Server 2005 ayan.mukherjee SQL Language 0 June 30th, 2008 03:34 AM
SQL Server Reg. SQL Server does not exist error Arsi SQL Server 2000 1 June 11th, 2008 11:20 AM
migrating from sql server 2000 to sql server 2005 abinashpatra SQL Server 2005 2 December 1st, 2006 03:45 PM
SQL Server sync with net server and browser server ne SQL Server DTS 0 June 13th, 2005 06:29 PM
SQL Server 7.0 talking to SQL Server 2000 msavage SQL Server 2000 1 August 20th, 2003 01:59 AM





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