Error deleting the file from the database

Hello,
all of asudden I get the following error message:
“Error deleting the file from the database: attempt to write a readonly database”.
It came out unexpectedly because in all the previous tests it work perfectly and I did not cahnge a thing.

I have three windows all connected to the same SQLite DB but different tables and report the same error.

The saving code is the same for all of them (except for the tables and ListBox names):

Dim bql As String
Dim i as Integer
Dim sql As String

//••••••••••••••••••••• Funzione di salvataggio dati nel DB SQLite esterno •••••••••••••••••••••


bql = "INSERT INTO Contr_Fatti (nome, junior, contratto, data) VALUES ( ?, ?, ?, ?);"

DB.BeginTransaction

var ok as boolean=true

sql  = "DELETE FROM Contr_Fatti"      // Comando Sql per eliminare tutte le righe salvate nel database Sql

If Contratti_Fatti.ListContrFatt.RowCount > 0 then
  
  Try
    DB.ExecuteSQL(sql) //Esegue il comando DELETE
    
  Catch err As DatabaseException
    MessageDialog.Show("Error deleting the file from the database: " + err.Message)
    Return
  End Try
  
  Try
    
    for i = 0 to Contratti_Fatti.ListContrFatt.LastRowIndex
      
      DB.ExecuteSQL( bql, Contratti_Fatti.ListContrFatt.CellTextAt(i, 0),  Contratti_Fatti.ListContrFatt.CellTextAt(i, 1), Contratti_Fatti.ListContrFatt.CellTextAt(i, 2),_
      Contratti_Fatti.ListContrFatt.CellTextAt(i, 3))
      
    next
    
    
  Catch err As DatabaseException
    MessageDialog.Show("Error deleting the file from the database: " + err.Message)
    Return
  End Try
  
  
else
  
  DB.ExecuteSQL(sql) //Esegue il comando DELETE
  
end if

if ok then
  DB.commit //solo ora salvi tutto
else
  DB.rollback 
end if

This code, probably not perfect, works in any other app I created but now it gives the error only in this single app I’m working on.

BTW, I granted unlimited permission to everyone on the SQLite DB

Any help would be appreciated

Thank you

  1. Your sql will delete all rows from the database.

  2. What “file” are you talking about? You are deleting rows.

  3. You have two identical error messages. Which one is output?

  4. What do you mean by " I granted unlimited permission to everyone on the SQLite DB"? Which “everyone”?

  5. What is it you are trying to do, using this code?

  1. Yes, it deletes them to repopulate. Probably not the right move but I was worried it could duplicate rows.

2 The Error dialog box talks about a file
Error then, once you click “Ok” this comes out
Exception

I don’t know what the first dialog refers to

3 You’re right. I missed it

4 Permissions, or rather Privileges, are dealt with and granted or blocked when you choose info for a file in a OSX environment


I thought it might be worth a try

5 I’m just trying to save in the SQL DB the row I add to the ListBox

If you could suggest a better way to handle the saving of a ListBox into SQL I’d appreciate it.

Thanks Tim

Try running chmod -R u+w /pathToDB/

cheers, Max

To keep the post alive, something funny happens: when I work on a project, I create a folder into which I put all the old versions of the app Im creating. Same thing I did for the app we are tlaking about in this post. Now, if I run the application from inside the OLD VERSION folder everything works. If I copy it outside the folder and do nathing but modify its name (i.e. Test 320 to Test 320a) without touching a single line of code I get the “Error deleting the file from the database: attempt to write a readonly database” message. I really don’t understand this behavior: the app name should not have any effect on its internal code