I'm making a C#program that interacts with some SQL Server databases. The problem is if I connect to a database (dbA) and then close this connection and open another one to another database (dbB) and then do a Restore of dbA, the SqlException triggers saying that database (dbA) is in use. However if I execute the program and connect only to dbB, I can restore the other databases without problem, is like the first connection is kept stored. Anyway here is the code where the connection should open and close:

```
private bool CheckConnection()
    {
        bool res = false;
        string conString = string.Empty;
        if (!String.IsNullOrEmpty(serverBox.Text) && !String.IsNullOrEmpty(dbBox.Text))
        {
            conString = ConcatConString(dbBox.Text);
            using (SqlConnection conn = new SqlConnection(conString))
            {
                conn.Open();
                if (conn.State == ConnectionState.Open)
                {
                    res = true;
                }
            }
        }        
        return res;
    }

```