• You don't need to do both

    cmd.ExecuteScalar())

    and

    cmd.ExecuteNonQuery()

    You're executing the same query twice, the 'ExecuteNonQuery' is unnecessary