I have an INSERT query and I want the DB to return the ID of the row I just inserted.
sqlString = \"INSERT INTO MagicBoxes (OwnerID, Key, Name, Permissions,
You have two options; you could declare an Output parameter called @ID; or - you could change the end to SELECT SCOPE_IDENTITY() and just use:
Output
@ID
SELECT SCOPE_IDENTITY()
int id = (int)cmd.ExecuteScalar();
I prefer the formal parameter approach, but ExecuteScalar works well.
ExecuteScalar