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: 
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();
      }
}

```
I believe you may want to consider a different approach if you consistently are processing 700 to 1000 or more invoice numbers at one time why not send all the invoice numbers down in a single query instead of many individual query's. As an example you could use an sql in list to do this as in below.

```
select
 *
from
 ivoice_table
where
 invoice_table.invoice_number in (123,124,125,126,127,128 etc....)

```

Enjoy!