Call the function, and add the returned value as a parameter:
using (SqlConnection connection = new SqlConnection("YOUR CONNECTION STRING HERE"))
using (SqlCommand command = new SqlCommand("UPDATE mytable SET id = 1 WHERE name = @name", connection))
{
command.Parameters.AddWithValue("@name", fetchname());
connection.Open();
command.ExecuteNonQuery();
}