Steve McArthur's Website
Microsoft Certified Professional Developer - C#, Ajax, ExtJS, ASP.net, LINQ, Oracle and SQL server Log in
  • Home
  • Blog
  • Ext Extensions
    • Date Calculator
    • CoinSlider
<< Ajax basics. |

Some kind of disk I/O error occurred–SQLite

Steve December 14, 2010 03:40

I got the extremely helpful “Some kind of disk I/O error occurred” message using the System.Data.SQLite .net assembly today. This was a big SQLite show stopper so I thought it was about time I figured out what was causing this.  The error was occurring when I tried to post an update to the SQLite database in the local App_Data folder of an asp.net application. As soon as the application attempted to post the update I got the dreaded “Some kind of..” error and a SQLite journal file was created in the database folder. After this, the database became unavailable. It became available again once the journal file was deleted, but I was then back in the same situation once another update was attempted. The curious thing was that this behaviour didn’t occur in the development environment, only when uploaded to the live server. My first thought was that the application for some reason didn’t have rights to write to the App_Data folder. But the journal file was writing to the location with no troubles. Finally I hit upon a forum post on the System.Data.SQLite forum here. This pointed in the direction of using the “PRAGMA” statement to set the journal_mode value to something other than “DELETE”. The PRAGMA statement is executed exactly like a query, so all that needs to be done is to execute the statement using a SQLiteCommand object in the same way you would execute any other SQL statement.

 

   1:  using (SQLiteConnection conn = new SQLiteConnection(sqliteConnectionString))    
   2:          {     
   3:              conn.Open();     
   4:              SQLiteCommand cmd = new SQLiteCommand();     
   5:              cmd.Connection = conn;  
   6:              string pragma = "PRAGMA journal_mode = OFF";     
   7:              cmd.CommandText = pragma;     
   8:              cmd.ExecuteNonQuery();
   9:   
  10:   
  11:          }


Posted in: SQLite  Tags: sqlite, database, errors
Leave Your Response

Related posts

Ajax basics.When we talk about Ajax we are usually talking about updating a web page without reloading the entir...

Comments

4/16/2011 6:43:05 PM #

I wish i can add your blog in my RRS, however i can't get the rrs address. Would you please help me?

Felco Secateurs People's Republic of China | Reply

4/18/2011 5:34:16 AM #

Have you tried
www.stevemcarthur.co.uk/blog/syndication.axd

Steve United Kingdom | Reply

1/26/2012 6:08:04 PM #

Do you have to execute this command each time you open the database or just when you create the database?

Cheers

Andy United Kingdom | Reply

5/3/2012 8:56:33 PM #

Yes.
And the disadvantage of turning the journal off is, that you can not rollback transactions.

Ron Germany | Reply

Saving the comment

Add comment

Cancel reply to comment




  Country flag

biuquote
  • Comment
  • Preview
Loading



x5467
Close Sidebar
RecentPosts
  • Some kind of disk I/O error occurred–SQLiteComments: 4Rating: 0 / 0
  • Ajax basics.Comments: 1Rating: 0 / 0
  • Calling ASP.net PageMethods from ExtJSComments: 11Rating: 0 / 0
  • Removing header from a flat file in BizTalkComments: 0Rating: 0 / 0
Blogroll
  • RSS feed for Ext JS BlogExt JS Blog
    • Deft JS: Loosely Couple...
    • Sencha Customer Spotlig...
    • Behind the Sencha Comma...
  • RSS feed for EncosiaEncosia
    • REST vs. RPC in ASP.NET...
    • Facebook is retaining I...
    • Someone should copy the...
Download OPML file OPML
Steve McArthur's Blog | © Copyright stevemcarthur.co.uk 2012. All Rights Reserved | Log in | About us | Example link
Steve McArthur's Website