toptensoftware/PetaPoco — pull request #95 by tawman (2011-12-29 14:57:09+00:00)
Title: Check connection state prior to Open() to avoid error: System.InvalidOperation

Encountered a scenario where the connection state was ConnectionState.Connecting when PetaPoco tried to issue _sharedConnection.Open(); to execute a query.

```
System.InvalidOperationException: The connection was not closed. The connection's current state is connecting.
at System.Data.ProviderBase.DbConnectionBusy.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at Samp.Core.Database.OpenSharedConnection() in C:\@Sample\projects\samp\src\Core\PetaPoco.cs:line 234
at Samp.Core.Database.d__7`1.MoveNext() in C:\@Sample\projects\samp\src\Core\PetaPoco.cs:line 747
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
at Samp.Core.Database.SingleOrDefault[T](Sql sql) in C:\@Sample\projects\samp\src\Core\PetaPoco.cs:line 1140
at Samp.Infrastructure.Services.SecurityRepository.UserHasAccessToReport(String userName, Guid reportId) in C:\@Sample\projects\samp\src\Infrastructure\Services\SecurityRepository.cs:line 51
at Samp.Web.Helpers.ReportAccessProvider.Authenticate(HttpContextBase context) in C:\@Sample\projects\samp\src\Web\Helpers\ReportAccessProvider.cs:line 35
at Samp.Web.Helpers.VerifyReportAccess.OnActionExecuting(ActionExecutingContext filterContext) in C:\@Sample\projects\samp\src\Web\Helpers\VerifyReportAccess.cs:line 13
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
at System.Web.Mvc.Controller.ExecuteCore()
at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.b__5()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.b__0()
at System.Web.Mvc.MvcHandler.<>c__DisplayClasse.b__d()
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
```