user: ### NOW ANSWER:
Question: When was the incumbent first elected in the district where the result was a Democratic-Republican gain? 
Columns: ['District', 'Incumbent', 'Party', 'First elected', 'Result', 'Candidates']
Types: ['text', 'text', 'text', 'text', 'text', 'text']
Sample row: ['Virginia 2', 'David Holmes', 'Democratic-Republican', '1797', 'Re-elected', 'David Holmes (DR) Alexander Sinclair (F)']
SQL:

assistant: SELECT "First elected" FROM "Table" WHERE "Result" = 'Democratic-Republican gain';