Hello,
how do you clear an SQLite database from all data?
I tried line by line with the following code:
" Sub Azzera()
'//•••••••••••••• AZZERA TUTTI I CAMPI •••••••••••••••
’
If Sommario.RiasList.SelectedRowIndex < 0 Then Return
Dim sql As String = “DELETE FROM Race WHERE ID = ?;”
Var id As Integer = Sommario.RiasList.SelectedRowIndex
Try
DB.ExecuteSQL(sql, id)
Catch err As DatabaseException
MessageDialog.Show("Error deleting the file from the database: " + err.Message)
End Try
End Sub
"
but I get an erro in line 5 (DB.ExecuteSQL(sql, id)). DB isn SQLite db declared in Globals and it is recognized in other methods.
I would like to deleted all rows in the SQLite database (Table named Race) so that I can have a pristine one in case I need
I tried all your seuggestions but I still get the same red X. I’m probably doing something wrong because if I use "Dim sql As String = “DELETE FROM Race WHERE ID = ?;” I get the screenshot I attach; if I use "Dim sql As String = “TRUNCATE FROM Race;” I get no errors but no deletion in the database.Screenshot of Xojo (06-05-2021, 09-01-30)|527x499
I modified the line of the method to “DELETE FROM Race;”. I also tried “TRUNCATE FROM Race;" version, both follwed by “DB.ExecuteSQL(sql, id)”
I do not get any errors anymore but I don’t get an empty SQLite db either. All the rows stay exactly as they were
DELETE FROM race
doesn’t have a parameter (will delete all the records)
so there is no need to repeat the call DB.ExecuteSQL(sql, id)
but you need only
DB.ExecuteSQL(sql)