How to use sqlite database for repeated calls - objective-c

In my project i need to call the sqlite database on constant basis. I got the database locked error which i kind of solved by giving sqlite timeout for 500ms. Stil sometimes i get the error. Is there any way not to lock the database error.?

Related

Query timeout expired while running a request from a packaged .NET tool

I am working on an application built using a .NET packaged configuration tool. There is a out of box request that in turn fires a delete SQL statement and tries to delete a row from the database. Since past few months, we are receiving the following error- [Microsoft][ODBC SQL Server Driver]Query timeout expired.
We are unable to simulate this scenario in lower environments and can see this issue only on production.
The only issue we think is there might be a deadlock issue in a situation where this delete request is deadlocking with another simultaneous insert in the table (we have a scheduled job that inserts data in a relational database from large XML-splitting data from nodes)
What can be done to resolve this? Note, indexing has been done on the tables recently that reduces the frequency for some time but it again spiked up.

SQL Server 2012: A way to see if the database has been tampered with?

I have a delicate situation wherein some records in my database are inexplicably missing. Each record has a sequential number, and the number sequence skips over entire blocks. My server program also keeps a log file of all the transactions received and posted to the database, and those missing records do appear in the log, but not in the database. The gaps of missing records coincide precisely with the dates and times of the records that show in the log.
The project, still currently under development, consists of a server program (written by me in Visual Basic 2010) running on a development computer in my office. The system retrieves data from our field personnel via their iPhones (running a specialized app also developed by me). The database is located on another server in our server room.
No one but me has access to my development server, which holds the log files, but there is one other person who has full access to the server that hosts the database: our head IT guy, who has complained that he believes he should have been the developer on this project.
It's very difficult for me to believe he would sabotage my data, but so far there is no other explanation that I can see.
Anyway, enough of my whining. What I need to know is, is there a way to determine who has done what to my database?
If you are using identity for your "sequential number", and your insert statement errors out the identity value will still be incremented even though no record has been inserted. Just another possible cause for this issue outside of "tampering".
Look at the transaction log if it hasn't been truncated yet:
How to view transaction logs in SQL Server 2008
How do I view the transaction log in SQL Server 2008?
If you want to catch the changes in real time, I suggest you consider using SqlDependency. This way, when data changes, you will be alerted immediately and can check which user is using the database at the very moment (this could also be done using code).
You can use this code sample.
Coming to think about it, you can establish the same effect using a trigger and writing ti a table active users. Of course, if you are suspecting someone is tempering with data, using SqlDependency might be a better way to go with, as the data will be stored outside of the tampered database.
You can run a trace, for example a distant profiler trace, that will get all SQL queries containing the DELETE keyword. This way, nobody will be aware that queries are traced. You can also query the default trace regularly to get the last DELETE commands: Maintaining SQL Server default trace historical events for analysis and reporting

NOLOCK error when attaching databases

One of my servers went down and I've had to move all my databases to another server. I want to use the "attach" functionality in SQL Server 2012 (these databases are SQL Server 2005).
For some reason I am getting a NOLOCK error on most of the databases when trying to attach them:
Could not continue scan with NOLOCK due to data movement.
Could not open new database 'db'. CREATE DATABASE is aborted.
File activation failure. The physical file name "D:\db\xxxx_log.ldf" may be incorrect.
New log file 'C:\db\xxxx_log.ldf' was created.
(Microsoft SQL Server, Error: 601)
Judging by the comments above, this database is well and truly broken, there are ways to recover it, one of which is detailed here:
Re-attaching, and fixing a SUSPECT database
But the problem with this is that you can never be sure what state the data is in, it is most likely transactionally inconsistent which will most likely cause you pain later on if you continue trying to use this.
Best thing to do is if you have a backup, restore that instead.

SQL Server 2005 won't update rows

I currently have a SQL Server 2005 set up and has been running successfully for quite a long period of time without any issues.
As of this morning our website applications have been attempting to perform udpates on various rows. However, every time an update happens the data never gets updated in the database.
Our application's code hasn't been changed in any way, and there appears to be no errors of any kind.
Is there anything in SQL Server that can prevent updates from being performed on a database? Can the size of transaction logs prevent data from being updated on a SQL Server database? Or anything at all that can cause this strange behaviour?
We had similar behaviour on one of our servers and it was due to the log file being on a hard drive that had run out of disk space - so worth checking that.
Also check that the Autogrowth limits haven't been reached:

Lock request time out period exceeded - Telerik OpenAccess ORM

I have a big SQL Server 2008 R2 database with many rows that are updated constantly. Updating is done by a back end service application that calls stored procedures. Within one of those stored procedures there is a SQL cursor that recalculates and updates data. This all runs fine.
But, our frontend web application needs to search through these rows and this search sometimes results in a
Lock request time out period exceeded. at
Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery()..
After doing some research I have found that the best way to make this query to run without problems is to make it run with "read uncommitted isolation level". I've found that this setting can be made in the Telerik OpenAccess settings, but that's a setting that affects the complete database ORM project. That's not what I want! I want this level for this query only.
Is there a way to make this specific LINQ query to run in this uncommitted isolation level?
Or can we make this one query to use a WITH NOLOCK hint?
Use
SET LOCK_TIMEOUT -1
in the beginning of your query.
See the reference manual
Runnung the queries in read uncommitted isolation level (and using NOLOCK hint) can cause many strange problems, you have to clearly understand why do you do this and how it can interfere with your dataflow