System.Data.SQLite.SQLiteException Attempting to write a read-only database in Windows 8

I developed an application that works fine <= Windows 7. It uses a SQLlite database with VB and C #. However, in Windows 8 (there has never been this specific problem on other Windows windows), a problem occurs when trying to write to the database

System.Data.SQLite.SQLiteException: Attempt to write a read-only database

I created a database file on Windows 8, for example:

 Try
     If (Not File.Exists(System.Environment.CurrentDirectory & "\MY_DB.db")) Then
                Dim conn = New SQLite.SQLiteConnection("Version=3;New=True;Compress=False;Read Only=False;Data Source=" & System.Environment.CurrentDirectory & "\MY_DB.db")
                conn.Open()
                '...DO STUFF  
                conn.Close()
                conn.Dispose()
                conn = Nothing
     End If

 Catch ex As Exception
            'Throw ex
            Return False
 End Try

But that did not work.

So basically I tried:

  • Added Read Only=Falsewhen creating a db file, but it does not work.
  • The folder in which the database is located must have write permissions, as well as the actual database file. So it didn’t work (on windows 7 it will look like enter image description here).

What can I do to record in databse format?

+4
1

, , , / .

, Environment.SpecialFolder enum?

-

 Try
      Dim appFolder = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
      appFolder = Path.Combine(appFolder, "MyAppDatabaseFolder")
      If Not Directory.Exists(appFolder) Then
           Directory.CreateDirectory(appFolder)
      End If
      Dim myDB = Path.Combine(appFolder, "MY_DB.db")
      If (Not File.Exists(myDB)) Then
          .....
      End If
 Catch ex As Exception
      'Throw ex
      Return False
 End Try
+4

All Articles