So I have a method which is supposed to check if a table exists in a database which is defined as follows:
internal override bool TableExists(string tableName)
{
    bool tableExists = false;
    // Check the Tables schema and see if the table exists
    using (SQLiteConnection conn = (SQLiteConnection) CreateConnection())
    {
        conn.Open();
        DataRow[] rows = conn.GetSchema("Tables").Select(string.Format("Table_Name = '{0}'", tableName));
        tableExists = (rows.Length > 0);
    }
    // Actually called elsewhere in the code, just here for testing.
    File.Delete(DatabaseEnvironmentInfo.GetPrimaryDataFile(DatabaseName));
    return tableExists;
}
CreateConnection() just creates a new connection with a connection string so I don't think the issue is there. If I have remove the line conn.GetSchema("Tables")... and I am able to delete the database file but if I add that line back in I get the following exception when I try to delete after the using:
System.IO.IOException: The process cannot access the file 'C:\db.sqlite' because it is being used by another process..
Do DataRowobjects keep a connection to the database or does anyone know what the issue could be? If there is a better way to check if a table exists in SQLite I am open to that as well.
Thanks!
 
     
     
    