I'm going to assume that you are using IDENTITY columns for your ID's so that SQL generates them for you - if not then you are using UNIQUEIDENTIFIER / Guid ID (in which case you could generate them when you do the INSERT and then you wouldn't need to ask this question).
So you need to fetch the value of the IDENTITY column that was just INSERTED - and SQL lets you do that with the
@@IDENTITY value or SCOPE_IDENTITY function[
^] value - you can retrieve that into your C# code by adding a SELECT command to your INSERT and replacing the call to ExecuteNonQuery with ExecuteScalar.