Question: I have a Navigation Controller in my main view. And I use the following code to add the navigation view when needed.

[self.view addSubview:navController.view];

However, the the navigation bar is not positioned correctly. I have posted a pic below. Anyone knows what is the potential problem?

![alt text](https://i.stack.imgur.com/jxZ7J.png)

Answer: 
Simply put all invoice nos in a IN statement and run this select statement in a single connection.
You can put your connection opening and closing code outside of your loop. That would make you only have one connection to the database. But that one connection would be open for a while. That's the trade-off. One connection open for a long time or lots of connections opening and closing.

I am also noticing that you are not closing your connection in the try code. Maybe try this.

```
public Invoice GetInvoice(string invoice)
{
      SqlConnection con = new SqlConnection(//connection string);
      SqlCommand cmd = new SqlCommand("dbo.getInvoices", con);
      cmd.CommandType = CommandType.StoredProcedure;
      cmd.Parameters.Add("invoice", SqlDbType.VarChar).Value = invoice;
      SqlDataReader dr;
      Invoice inv = new Invoice();
      try{
            con.Open();
            dr = cmd.ExecuteReader
            while(dr.read())
            {
                 //assign values from the database fields
            }
      }
      catch{}
      finally
      {
        con.Close();
      }
}

```