473,412 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

SQL Server Compact timed out waiting for a lock

Hi all,
I'm having an application in that i use Sql Compact 3.5 with VS2008. I'm running multiple threads in my application which contacts the compact database and accesses the row. It selects and deletes those rows in a fashion i.e selecting and giving to the application 5 rows and deleting those rows from the table. It works great with a single thread but if i use multiple threads i.e if 3 or more threads are running I get very often the TimeOut Error!!! I have increased the Time out property in the connection string but it didn't give me expected result. The error log is as follow:

SQL Server Compact timed out waiting for a lock. The default lock time is 2000ms for devices and 5000ms for desktops. The default lock timeout can be increased in the connection string using the ssce: default lock timeout property. [ Session id = 5,Thread id = 4204,Process id = 4808,Table name = XXX,Conflict type = x lock (s blocks),Resource = TAB ]

The Query that I use to retrieve is as follows:

"
select Top(5) * from TableName order by id;
delete from TableName where id in(select top(5) id from TableName order by id);
"

Is there any way by which we can avoid this Time Out exception???????

The above query I un as a transaction in VS2008 one using SQLCECommand and the other using SqlCEDataAdapter.

Any Idea!!!!!!
Sep 12 '09 #1
4 6114
ck9663
2,878 Expert 2GB
Once the selected statement is returned, do you display that on your GUI first then delete it after a click of a button or something? You might want to consider modifying your design. You can gather the ID that was displayed and delete only those ID on your table. Not use a query. You might encounter a problem, specially if there's a NULL on your ID.

You may also give more detail on your application. Let's see if we may be able to suggest some other way.

Happy Coding!

--- CK
Sep 12 '09 #2
Hi,
Thanks for the reply.

Ya i use those values in my application for further processing. one command inserts the records in the table and so soon as the records are inserted it is used by the application. To make the process fast I've multiple threads that contact the table and uses the records. Each thread takes five-five records does the job. The records are used in the application for further processing and it's not for displaying in GUI but at the backend for processing and hence I don't want duplicate records also and so I'm using delete query to delete the record. It works properly if I've just one thread but if I have more threads say nearly five or ten than I get those TIMEOUTEXCEPTION and my process gets slow down.

So is there any way by which these exceptions can be avoided????????

The table has one Primary Key called ID using which I retrieve or delete the records!!!.
Any Idea!!!!!!!!!!!!!
Sep 14 '09 #3
ck9663
2,878 Expert 2GB
Why not do an update of record if it's existing. Your delete could be locking everyone so no one can access it. You might also have a big table that the delete is taking a while, hence the timeout.

Good luck!!!

--- CK
Sep 15 '09 #4
Hi,
Thanks for the reply...

I don't need those records again to be used and hence i'm deleting it. Ya table is big. It may contain hundred records or one lakh records depending on user's choice. Mostly ten thousand records will be there and once i get the record i don't want to use them again and hence i need to delete them!!!!!!!!
hmmm........ So update will not work in my scenario......
Sep 16 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: David | last post by:
Hi Below is a copy of the top 5 timed events from my statspack. Don't know how to detect what enqueue waited for what. Don't understand Oracle Documentation's description on how to check...
44
by: Charles Law | last post by:
Hi guys. I'm back on the threading gig again. It's the age-old question about waiting for something to happen without wasting time doing it. Take two threads: the main thread and a worker...
4
by: Prince Kumar | last post by:
I joined a company recently and they have a java program which hangs (does nothing) after a while. This is no way consistent. It could succeed quite a few times and can fail a few other times....
14
by: Steve Jorgensen | last post by:
I just got paid to solve this problem for one client, so I might be impeding future business opportunities by sharing this secret, but a rising tide floats all boats, so... I've seen this...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
16
by: Bruce Wood | last post by:
Maybe it's just late in my day, but I'm reading Jon's article on threading, in particular how to use Monitor.Wait() and Monitor.Pulse(), and there's something that's not sinking in. The code in...
7
by: Samuel | last post by:
Hi, I am looking for some recommendations for client/server technologies and for the communication involved. I am currently planning to port a Perl application that has grown out of...
7
by: David | last post by:
i think i just realized i'm an idiot. again. (not syntactically correct code... just pieces to illustrate) class StateObject { members like socket, receiveBuffer, receiveBufferSize,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.