I'm using SQL Server Compact in my C# project. My database has a Users table that has two columns - an ID column (PRIMARY KEY) and a Username column. I keep track of various users that interface with my system by inserting their username in the Users table.

When a user contacts the system, I want to record their name in the table if they aren't already there. Obviously, I could add the UNIQUE keyword to the Username column, but that means I need to handle exceptions for duplicate entry attempts. Once the name is in the table - either because it already exists or I had to add it - I need to get the corresponding ID.

Here's some working code to shoot at.

```
public void GetUserId(string username)
{
    using (SqlCeCommand selcmd= new SqlCeCommand(
        "SELECT * FROM users WHERE username = @user", conn))
    {
        selcmd.Parameters.AddWithValue("@user", username);
        SqlCeResultSet rs = selcmd.ExecuteResultSet(ResultSetOptions.Scrollable);
        if (!rs.HasRows)
        {
            using (SqlCeCommand inscmd= new SqlCeCommand(
                "INSERT INTO users (username) values (@user)", conn))
            {
                inscmd.Parameters.AddWithValue("@user", username);
                inscmd.ExecuteNonQuery();
            }

            rs = selcmd.ExecuteResultSet(ResultSetOptions.Scrollable);
        }

        rs.ReadFirst();

        return (rs.GetInt32(rs.GetOrdinal("id")));
    }
}

```

Is there any way to do this more efficiently?