0) Use a parameterized statement.
1) No reason to use a transaction for an individual operation.
2) Stop instantiating and disposing everything on each cycle; reuse what you have.
3) If you're passing in a connection, why throw it out?
4) WTF with that Linq? :omg:
5) Consider sending in multiple IDs rather than just one and then loop within the Delete method.
6) I also advise against deleting; generally, setting a status of some sort to indicate active/inactive is a better technique in the long run.
Rough and unready, but should give an idea:
public static void Delete(IEnumerable<int> Idlist)
{
using (SQLiteConnection conn = new SQLiteConnection(blah blah) )
{
conn.Open();
string delete = @"DELETE FROM Person WHERE Id =@id;";
using (SQLiteCommand command = new SQLiteCommand(delete,conn))
{
command.Parameters.Add ( new parameter ... ) ;
command.Transaction = conn.BeginTransaction() ;
foreach ( int id in Idlist )
{
command.Parameters [ 0 ].Value = id ;
command.ExecuteNonQuery();
}
command.Transaction.Commit();
}
conn.Close();
}
}
See also:
Simplified Database Access via ADO.NET Interfaces[
^]