Getting the primary key of a newly inserted row in SQL Server CE and C#?

c#, compact-framework, sql, sql-server-ce

Solution

Assuming your primary key is an identity field, you can use the query `SELECT @@IDENTITY` after you insert your new row.

Problem

I'm doing an insert into a SQL Server CE table where the primary key is auto-generated, how would I go about getting the primary key after the insertion completes?

Original source