I am deleting from an sqlite database using the ids of the records like this
(the dirID
is an array of the IDs):
Dim i As Integer = 0
Dim conn As New SQLiteConnection("Data Source=" & DBPath)
Dim cmd As New SQLiteCommand("DELETE FROM directory WHERE id IN (@ID)", conn)
cmd.Parameters.AddWithValue("@ID", Join(dirID, ","))
'conn.SetPassword(dbPassword)
conn.Open()
Try
mytransaction = conn.BeginTransaction()
'// delete directory //
If dirID IsNot Nothing Then
cmd.ExecuteNonQuery()
End If
mytransaction.Commit()
conn.Close()
Catch ex As Exception
mytransaction.Rollback()
strLastError = ex.Message
Debug.Print(strLastError)
Finally
cmd.Dispose()
conn.Dispose()
End Try
The problem is that it doesn't always delete from the database, and its not throwing any errors.
Could there be a better way of deleting?